Question 86
What is the output of the following C program?
C
#include <stdio.h>
int fun(int n) {
if (n <= 1) return 1;
return fun(n - 1) + fun(n - 2);
}
int main(void) {
printf("%d", fun(6));
return 0;
}Detailed Solution
fun(0)=1, fun(1)=1, fun(2)=2, fun(3)=3, fun(4)=5, fun(5)=8, fun(6)=13.
✓ Saved