ProgrammingHardTCS NQT · Infosys

int x = 0, y = 1; What does printf("%d", !x == y) print?

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

Correct answer: B. 1

! binds tighter than ==, so !x is 1 when x is 0. Then 1 == y is 1 == 1, which is true and prints 1.

More C Programming questions

Exams that ask this topic