Sorry for posting question

Sorry for posting wrong question in this forum.

These questions look like they are from your college assignment .Please do not expect us to do your homework for you. Use google, wiki ,text books, etc and try to make something on your own first. If you make mistakes there , we are more than will to help in correcting them.

I already tired my self , then i came over here as i am beginner i was getting so many errors as results.But thanks for your KIND ANSWER .

Please give us links to code on ideone or some other site to let us see how much you have done. We can help you from there. Stackoverflow is the best resource for such queries.