ProgrammingModerateTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer x = 3
x = x << 2
x = x + (x >> 1)
Print x
  1. A. 24
  2. B. 18
  3. C. 15
  4. D. 21

Correct answer: B. 18

3 << 2 = 12 (multiply by 4); 12 >> 1 = 6; 12 + 6 = 18.

More Pseudocode and Code Tracing questions

Exams that ask this topic