ProgrammingHardTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer x = 5, y, z
y = x++ * 2
z = ++x + y
Print x, y, z
  1. A. 7 10 17
  2. B. 6 10 16
  3. C. 7 12 19
  4. D. 7 10 16

Correct answer: A. 7 10 17

y = 5 x 2 = 10 and then x becomes 6; ++x makes x = 7 before use, so z = 7 + 10 = 17.

More Pseudocode and Code Tracing questions

Exams that ask this topic