MCQ
Single Best Answer
Moderate
QConsider the following program segment in which the statements are jumbled.
Choose the correct order of statements to calculate and return the factorial of 4.
-
for (k=1; k<=4; k++) -
return fa; -
long fa = 1, k; -
fa *= k;
ID: #24168
ICSE Computer Application - Class X - 2025 PYQ
77 views
Question Info
#24168Q ID
ModerateDifficulty
ICSE Computer Application - Class X - 2025 PYQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option B
Explanation
(b) 3, 1, 4, 2
Correct Order:
-
long fa = 1, k;→ (Initializefato store factorial) -
for (k=1; k<=4; k++)→ (Loop through numbers 1 to 4) -
fa *= k;→ (Multiplyfabykin each iteration) -
return fa;→ (Return the computed factorial)
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic