Question 41
What is the output of the following C code?
C
#include <stdio.h>
int fun(int x, int y) {
if (x == 0) return y;
return fun(x - 1, x + y);
}
int main(void) {
printf("%d", fun(4, 3));
return 0;
}Detailed Solution
fun(4,3) -> fun(3, 4+3=7) -> fun(2, 3+7=10) -> fun(1, 2+10=12) -> fun(0, 1+12=13) -> returns 13.
✓ Saved