Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 1 : 43 / 43
Advertisement
Detailed Solution
सही उत्तर 43 / 43 है।
Key Points
Helpful?
Question:
What is the output of the following C code? `int f(int n){ return n<=1 ? 1 : n*f(n-1) + f(n-2); } int main(){ printf("%d", f(4)); }` / निम्नलिखित C कोड का आउटपुट क्या होगा? `int f(int n){ return n<=1 ? 1 : n*f(n-1) + f(n-2); } int main(){ printf("%d", f(4)); }`
1.
43 / 43
2.
24 / 24
3.
34 / 34
4.
10 / 10
Correct Answer: 43 / 43
f(0)=1, f(1)=1, f(2)=2×1+1=3, f(3)=3×3+1=10, f(4)=4×10+3=43. The trap option (b) mistakes the function for a plain factorial, ignoring the added `f(n-2)` term. / f(0)=1, f(1)=1, f(2)=2×1+1=3, f(3)=3×3+1=10, f(4)=4×10+3=43। जाल विकल्प (b) function को साधारण factorial समझता है और जुड़े हुए `f(n-2)` पद को नज़रअंदाज़ करता है।
Downloaded from PrepSnap (prepsnap.in)