Question 132

What is the output? int f(int n) {

What is the output? int f(int n) { if (n <= 1) return 1; return n * f(n - 1); } printf("%d", f(5));
  1. A15
  2. B120
  3. C720
  4. D24
Show answerHide answer

Correct answer: (B) 120

Explanation

f computes factorial: 5! = 120.

From DSSSB TGT Computer Science Full Mock Test 1

This is question 132 of DSSSB TGT Computer Science Full Mock Test 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.