Thanks for that tip:) But initially my code was in this format only.
printf("%d\n",sum);
I changed it just to check whether that was the bug. And it didn't turn out to be.
Yes. I did read that comment. In fact even I seemed to get right answers for numbers greater than 999,999,999. ( I verified the answers with this : javascripter.net/math/calcul ... ulator.htm)
I really don't understand where I am going wrong.
Please help!