hnaya, an observation. You opened with "i have difficulty to write algorithm to following programs in c language ". I asked: "What does it do, and how does it do it?" and in answer you said "i want the algorithm for each one"
Yes, I know you want the algorithm for each one.
No, I'm not going to write it for you. (Someone else might though.)
But I will help you write it, if you're willing to learn. So please answer my first question: "What does it do, and how does it do it?" (You may need to mention if you haven't got a clue how it works though; if you don't know that, you're definitely not going to be able to write the algorithm.)
Lots of people post homework assignments expecting us (a) to write it for them and (b) not to be smart enough to realise that's what we're doing and (c) trustworthy enough that if we do realise, we won't write something for you that is plausible but significantly wrong. If that's what you're doing, you're not the first, you won't be the last, and it's very easy to spot (the key giveaways are the lack of willingness to learn and a "just give me the fscking answer" attitude).