You can't just post a bunch of homework questions and expect us to do them for you. Try one of them and post your code. Tell us what you tried and what you're having troubles with. We can then assist you with the solution.
I am sorry but, this is not a homework. I am trying to practice on writing programs. I thought that maybe I'll be able to understand by following the practice's solution.
Thank you very much MiiNiPaa you are the best. I still need the solution of the other two questions.
You're trying to practice writing programs by looking at the solutions???
That's like practicing guitar playing by watching MTV. You'll never learn to write programs unless you actually write programs.
Thank you again MiiNiPaa i really appreciate your help. Dear cnoeval thank you for your reply but, every one has his own way to learn and this is my way. First I look at the general idea then I go deep to see the details. Its just a way to learn maybe it doesn't work with you but I think it works with me.