Important MCQ

The factorial of 4 calculated by a while loop is

Q.The factorial of 4 calculated by a while loop is

A) 12
B) 24
C) 10
D) 16
Correct Answer:
Option B
Detailed Explanation:
B) 24 is correct. A while loop checks its condition before each iteration, so it may run zero times. The loop body must update state when needed to avoid an unintended infinite loop.