ProgrammingModerateAccenture · Capgemini

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer a = 5, b = 9
a = a ^ b
b = a ^ b
a = a ^ b
Print a * 10 + b
  1. A. 59
  2. B. 14
  3. C. 45
  4. D. 95

Correct answer: D. 95

The three XOR steps swap a and b, so a = 9 and b = 5, and a * 10 + b = 95.

More Pseudocode and Code Tracing questions

Exams that ask this topic