ProgrammingModerateTCS NQT · Infosys

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer i, s = 0
for (i = 1; i <= 20; i = i + 3)
    s = s + i
end for
Print s
  1. A. 70
  2. B. 63
  3. C. 66
  4. D. 76

Correct answer: A. 70

The loop adds 1, 4, 7, 10, 13, 16 and 19, giving 70.

More Pseudocode and Code Tracing questions

Exams that ask this topic