ProgrammingHardTCS NQT · Infosys

int x = 2; printf("%d", x & 1 == 1); prints what?

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

Correct answer: A. 0

== binds tighter than &, so the expression is x & (1 == 1), which is x & 1. For x = 2 that is 0, because the low bit is clear.

More C Programming questions

Exams that ask this topic