Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 3 : 24 / 24

Advertisement

Detailed Solution

सही उत्तर 24 / 24 है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What is the output of the following C program involving a recursive factorial function? / पुनरावर्ती फैक्टोरियल फ़ंक्शन वाले निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h> int f(int n) { return (n <= 1) ? 1 : n * f(n - 1); } int main() { printf("%d", f(4)); return 0; }

1.
6 / 6
2.
12 / 12
3.
24 / 24
4.
120 / 120

Correct Answer: 24 / 24

f(4) computes 4 × 3 × 2 × 1 = 24 through recursion. / f(4) पुनरावृत्ति से 4 × 3 × 2 × 1 = 24 परिकलित करता है।

Downloaded from PrepSnap (prepsnap.in)