Consider the following two functions.
void fun1(int n) { if(n == 0) return; printf("%d", n); fun2(n - 2); printf("%d", n); } void fun2(int n) { if(n == 0) return; printf("%d", n); fun1(++n); printf("%d", n); }
The output printed when $\text{fun1}(5)$ is called is
Whenever we take a static variable, until function calls are over we won't print the value i.e. we take the last updated value after the function call and then we print it,but if the variable is global then why do we directly take the value and print it .?Here second printf stmt i.e.stmt after function call we fixed the value into the variable and it's been printed at the end.why?
https://www.youtube.com/watch?v=V7n6aFiBb7s
hence correct answer is a.
Ray Tomlinson in $f_2()$ after the printf statement there is a pre-increment of variable $n$.
ANS)A
In fun2,value of n also get incremented after each function call.
\
Solution......
64.3k questions
77.9k answers
243k comments
79.7k users