What is wrong with my code? Please help. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is wrong with my code? Please help.

I made a C programme to find out sum of digits of a given number, but failed to get desired result. It's output is too long. https://code.sololearn.com/cg52o0JzHdui/?ref=app

12th Aug 2018, 2:22 PM
rakesh rajak
rakesh rajak - avatar
3 Answers
+ 1
In the last statment of while loop, it should be a=a/10 instead of a=a%10 and put the print statement outside while loop, hope it helps.
12th Aug 2018, 4:01 PM
Shubham Goel
+ 1
Yes, now it's working correctly. Thanks for helping me.
13th Aug 2018, 1:50 AM
rakesh rajak
rakesh rajak - avatar
+ 1
Happy to help 🙂
13th Aug 2018, 6:52 AM
Shubham Goel