πŸ“Š C Programming
Q. What will be the output of the following code snippet?
Code:
#include <stdio.h>
int get(int n) {
    if(n <= 1) {
        return n;
    }
    return get(n - 1) + get(n - 2);
}
void solve() {
    int ans = get(6);
    printf("%d", ans);
}
int main() {
    solve();
	return 0;
}
  • (A) 5
  • (B) 1
  • (C) 0
  • (D) 8
πŸ’¬ Discuss
βœ… Correct Answer: (D) 8

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
177
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Manisha Agrawal
Publisher
πŸ“ˆ
80%
Success Rate