GATE Computer ScienceVery hardGATE CS (PYQ pattern)

int a = 5, b = 3, c = 2; int x = a + b << c > 20; int y = 6 & 3 == 3; int z = 1 + 2 * 3 % 4 - 5 / 2 | 8 >> 2; printf("%d %d %d", x, y, z); What is printed?

  1. A. 1 2 3
  2. B. 1 0 3
  3. C. 0 0 3
  4. D. 1 0 1

Correct answer: B. 1 0 3

Precedence: + above <<, << above >, == above &, and * % / above + -, which are above >> which is above |. x = ((5+3) << 2) > 20 = 32 > 20 = 1. y = 6 & (3 == 3) = 6 & 1 = 0. z = ((1 + (6 % 4) - 2) | (8 >> 2)) = (1 + 2 - 2) | 2 = 1 | 2 = 3.

More Programming and Data Structures (GATE) questions

Exams that ask this topic