+ 2
pls give explanation {r=n%10; s=s+r; n=n/10} this program in sum of the digit
solve this function
11 Respuestas
+ 4
this program will get the sum of each digit I'm the number
if number is 1987
sum = 1+9+8+7 = 25
+ 4
n = 1987
s = 0
r = 1987 % 10 = 7
s = 0 + 7 = 7
n = 1987 / 10 = 198
r = 198 % 10 = 8
s = 7 + 8 = 15
n = 198/10 = 19
r = 19%10 = 9
s = 15 + 9 = 24
n = 19/10 = 1
r = 1%10 = 1
s = 24 + 1 = 25
n = 1/10 = 0
+ 3
the first line will just get the number of the last digit
second line at the number into sum
third line will get rid of the last digit in the number for next operation
These three lines of code needs to be done in loop for the condition while(n!=0)
0
sum of the digit
{ r=n%10;
s=s+r;
n=n/10;
}
pls explain this function
0
do {digit= n % 10; n = n / 10; M = M*
10 + digit;} while (n > 0);
0
n%10
0
1%10
0
5%10
0
2%10
0
Temp//=10
0
How to write temp//=10