0
Runtime error
Don't know what's wrong having no output, if sum > 9. https://code.sololearn.com/cexB4F7bv8tw/?ref=app
7 Réponses
+ 1
I don't know what you want to do but if you want to add each element of any number then do like this :-
while(x > 0)
{
rem=x%10;
sum+=rem;
x/=10;
}
return sum;
0
Could you please explain the code.
What should the code do?
0
Avinesh
It should print the sum of each single digits,
If and only if sum is a single digit number.
Ex : n=5347, sum= 5+3+4+7 = 19 ( having two digits, thus again take sum of current sum(19).
Sum=1+9 = 10,
Again take sum.
Sum = 1+0 = 1 ( since sum is a single digit number, print sum = 1).
0
~ swim ~
Should I try making it local...