# Data Structure Questions and Answers-Fibonacci using Recursion

## Data Structure Questions and Answers-Fibonacci using Recursion

 Question 11 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the output of the following code?

`int fibo(int n) { if(n == 1) return 0; else if(n == 2) return 1; return fibo(n - 1) + fibo(n - 2); } int main() { int n = 5; int ans = fibo(n); printf("%d", ans); return 0; }`
 A 1 B 2 C 3 D 5
Question 11 Explanation:
The program prints the 5th fibonacci number, which is 3.

 Question 12 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
How many times will the function fibo() be called when the following code is executed?

`int fibo(int n) { if(n == 1) return 0; else if(n == 2) return 1; return fibo(n - 1) + fibo(n - 2); } int main() { int n = 5; int ans = fibo(n); printf("%d", ans); return 0; }`
 A 5 B 6 C 8 D 9
Question 12 Explanation:
The function fibo() will be called 9 times, when the above code is executed.

 Question 13 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the output of the following code?

`int fibo(int n) { if(n == 1) return 0; else if(n == 2) return 1; return fibo(n - 1) + fibo(n - 2); } int main() { int n = 10; int ans = fibo(n); printf("%d", ans); return 0; }`
 A 21 B 34 C 55 D 13
Question 13 Explanation:
The program prints the 10th fibonacci number, which is 34.

There are 13 questions to complete.