The good part is that it is not actually a solution, so you are technically not handing out an answer to a homework question before the question asker has come closer to a solution.Originally Posted by vikasvijayan
On the other hand, it seems that you did intend to give an actual solution. To keep to the spirit of the [url=http://cboard.cprogramming.com/c-programming/announcement-homework.html]homework policy, please do not do others homework. Normally, this rule is more for question askers than help providers, but you have basically tried to provide solution, however incompetently, for many of your past posts, so consider this an unofficial warning.
Oh, and void main should be int main.