+ 1
explain the output?
#include <stdio.h> int i=0; int fun(int a){ i++; if(a>99) return a-12; return fun(fun(a+25)); } void main() { printf("%d",fun(69)); printf("%d",i); }
1 Respuesta
+ 1
this algorithm uses recursivity functions.
Look, in The first fun call, you're if is false, so, next line isn't executing.
a = 69, so , now is same function but this time 69 + 25 .
In this case, if is true, so the output to the first printf is a - 12 = 69 - 12 = 57.
For The next one, you've to add every time you begin fun() because i++.
The result for this print is 2.
I hope I explain It well:)