+ 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); }

14th Jun 2019, 9:42 AM
keerthi
keerthi - avatar
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:)
9th Jul 2019, 5:32 PM
Daniel GG
Daniel GG - avatar