Code:
{
int a;
a=3;
fun(a);
system("PAUSE");
return 0;
}
void fun(int n)
{
if (n>0)
{
fun(--n);
printf("%d",n);
fun(--n);
}
}
1. At first 3 is passed to fun
2. if checks 3>0 since it is true control goes inside the loop
3. In the loop again fun(==3) so fun(2), again if(2>0).
4. Likewise if(0>0) will be false and atlast the program will not print anything.
But my compiler provides the answer as 0120
Kindly provide the clarification. Thanks in advance
Comment