Possible Duplicate:
What is really happening in this code?
in this problem i cant apply my concepts of recursion
#include<stdio.h>
count(int);
main()
{
int x=4;
count(x);
return 0;
}
count(int n)
{
if(n>0)
{
count(n-1);
printf("%d",n);
count(n-1);
}
}
when we run the program count(4),count(3),count.....count(0) is stored in stack…but when count(0) is called and the if condition is false..then where does the control go? please if anyone can explain with the help of a diagram showing various function calls.
can you try the following piece of code.