ProgrammingModerateTCS NQT · Accenture 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.)
Integer a = 12, b = 10
Print a & b, a | b, a ^ b
  1. A. 8 14 6
  2. B. 8 14 2
  3. C. 2 14 6
  4. D. 10 12 6

Correct answer: A. 8 14 6

12 = 1100 and 10 = 1010. AND = 1000 = 8, OR = 1110 = 14, XOR = 0110 = 6.

More Pseudocode and Code Tracing questions

Exams that ask this topic