Question PSC-LOOP-0006
EasyWhat will be the output of the following pseudocode?
Integer x = 1
for (each i from 1 to 3)
x = x * 2
end for
Print x
- A.
6
- B.
16
- C.
Show answer and explanation
Answer: D
x doubles three times: 1 → 2 → 4 → 8.
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 x = 1
for (each i from 1 to 3)
x = x * 2
end for
Print x
6
16
Answer: D
x doubles three times: 1 → 2 → 4 → 8.
4
8