0
How it will work..??
i=n%10; sum=sum+i;/*sum=o*/ n=n/10;
5 Respostas
+ 7
say n = 25
the % modulo operator returns the remainder if two numbers are divided unequally. So
i = n % 10 ---> i = 25 % 10
i = 5
sum = sum + i ---> 0 = 0 + 5
sum = 5
n = n / 10 ---> 25 = 25 / 10
n = 2
on next iteration
i = 2 % 10
i = 2
sum = 5 + 2
sum = 7
+ 2
sowmiya its because whenever the number to the left of modulo operator is less than the number to the right of modulo operator, the answer will always be equal to the number that is on the left side of modulo operator
That's why i = 2 % 10 ---> i = 2
+ 1
my doubt is cleared...thanks bro..
0
i=2%10...HOW IT BECAME I=2..???
0
yes bro..i understood...
tanq..