This recursive function puzzles me, what is going on?
Posted
by Fred
on Stack Overflow
See other posts from Stack Overflow
or by Fred
Published on 2010-04-06T22:04:40Z
Indexed on
2010/04/06
22:13 UTC
Read the original article
Hit count: 226
I was playing around with recursion and did this simple function. I was assuming that it would print out 9-0 to stdout, but, it prints 0-9. I can't see how that happens at all.
int main()
{
rec(10);
return 0;
}
int rec(int n){
if(n > 0)
printf("%d\n", rec(n -1));
return n;
}
© Stack Overflow or respective owner