Code:int x=1234; int y = func(x); int func(int x) { int j; if (x <10) return x; else { j = x%10 + func(x/10); printf("%d",j); } }
it outputs the sum of digits
since there is no statement like return j; in the else part of func, hence 3 is printed first and then 2 random numbers after that...
if the else part is like :
else {
j = x%10 + func(x/10);
printf("%d",j);
return j;
}
then the ouptut is:
3610
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks