All of your question asked on CP are of basic level.
I think nobody will provide code for this type of simple task.
And please Google your query before posting on CP and if you are unable to find any suitable solution than ask on CP.
Here is you
answer[
^].