ProgrammingHardWipro NLTH · Cognizant GenC

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer i = 5, j
j = (i++) + (++i)
Print i, j
(i++ gives the old value and then adds 1; ++i adds 1 and then gives the new value; operands are evaluated left to right.)
  1. A. 7 11
  2. B. 6 12
  3. C. 7 10
  4. D. 7 12

Correct answer: D. 7 12

i++ gives 5 (i becomes 6), ++i makes i = 7 and gives 7: j = 12 and i = 7.

More Pseudocode and Code Tracing questions

Exams that ask this topic