Question PSC-LOOP-0004
EasyWhat will be the output of the following pseudocode?
Integer f = 1
for (each i from 1 to 4)
f = f * i
end for
Print f
- A.
120
- B.
24
- C.
Show answer and explanation
Answer: B
f = 1 × 2 × 3 × 4 = 24 (4 factorial).
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Loops question
What will be the output of the following pseudocode?
Integer f = 1
for (each i from 1 to 4)
f = f * i
end for
Print f
120
24
Answer: B
f = 1 × 2 × 3 × 4 = 24 (4 factorial).
10
4