0
int foo(int n,int r){ if(n>0) return (n%r+foo(n/r,r)); else return 0; } int main (){ printf("%d",foo(345,10)); }
Why is output 12??
1 ответ
+ 2
n%r will give 5 and then func will run again with 34 and 10
Now n%r will give 4 and then func will run again with 3 and 10 ,now n%r will give 3 and func will run again with 0 and 10 but now since n is equal to 0 ,0 will be returned and func stops executing
So we have 5+4+3 now