Magtanong at makakuha ng mga sagot ng eksperto sa IDNStudy.com. Magtanong ng anumang bagay at makatanggap ng kumpleto at eksaktong sagot mula sa aming komunidad ng mga propesyonal.

A program that would ask for sn integer input snd displays the sum and displays the sum of the digits in the integer.



Sagot :

Instead of storing it as an int, store it as a string, an array of char.  Then, add the its digits using a loop.  Oh, and don't forget to use atoi before operatinf if you want to right.  atoi means alpha to integer, it converts your char type number to an int one

Hope this helps :)
p.s. If there is a part of my solution that you did not understand, please do not hesitate to contact me and I'll be more than glad to explain it to you thoroughly