no offence prakash0104 lolguy,but if you notice the OPs post #11 you can see that he/she had already got the solution partly...the point was to help the OP build the basics of C, not to spoon-feed him/her and give ready-made answer...as that would not help in the long run...(see homework policy)