ProgrammingHardCapgemini · Infosys pattern

What will be the output of the following pseudocode? (& is bitwise AND, | is bitwise OR, ^ is bitwise XOR, << and >> are left and right shifts.)

What will be the output of the following pseudocode? (& is bitwise AND, | is bitwise OR, ^ is bitwise XOR, << and >> are left and right shifts.)
Print ((13 & 7) << 2) | (9 >> 2)
  1. A. 23
  2. B. 22
  3. C. 54
  4. D. 20

Correct answer: B. 22

13 & 7 = 1101 & 0111 = 0101 = 5. 5 << 2 = 20 = 10100. 9 >> 2 = 2 = 00010. 20 | 2 = 10110 = 22.

More Pseudocode and Code Tracing questions

Exams that ask this topic