With all due respect this feels like a homework question.
I suggest you consult your friendly neighbourhood search engine (e.g.
Google) as this has been asked a million times.
For example the following links might shine some light on your questions and for the most part were found by simply taking your question you typed there and giving it to Google (some slight syntax changes were made in some situations).
Link 1[
^]
Link 2[
^]
Link 3[
^]
You can figure out which questions the links answer for yourself as it should be pretty obvious. If they are too complex for you, then I suggest you revisit said search engine :-)