ProgrammingHardTCS NQT · Product company OA

What is printed?

What is printed?
int x = 3, y = 1;
printf("%d %d", !x == y, !(x == y));
  1. A. 1 0
  2. B. 0 0
  3. C. 1 1
  4. D. 0 1

Correct answer: D. 0 1

Unary ! binds tighter than ==, so !x == y means (!x) == y = 0 == 1 = 0. !(x == y) negates 3 == 1, which is false, giving 1. Moving the ! changes what it applies to.

More C Programming questions

Exams that ask this topic