+ 1
Can anyone tell me how is it printing '012' ?
#include<stdio.h> void fun(int n) { if(n>0) { fun(--n); printf("%d",n); } } int main() { int a=3; fun(a); return 0; }
5 Answers
+ 1
I do understand how is it happening
like when n becomes 0 after all the decrements
it return back to fun (1) and prints the the value of n which is 0
and after that it goes to fun (2) where it prints 1
and after that in fun(3) it prints 2
Then the compiler gets out of the function fun ()đ
0
#Rewa Mathur
I just wanted to know after n becomes 0
What happens next ?
Thanks by the way i got my answer
0
Gordie
I agree with you i need to see more deeply in the recursive functions
0
I just somehow forgot that the compiler will come back to printf after the decrementing processes are done