ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
int a = 3, b = 4, c = 5;
int r = a + b == c ? 1 : 0;
printf("%d", r);
  1. A. 1
  2. B. 0
  3. C. 7
  4. D. Compilation error

Correct answer: B. 0

+ binds tighter than ==, which binds tighter than ?:, so this is ((a+b) == c) ? 1 : 0 = (7==5) ? 1 : 0 = 0.

More C Programming questions

Exams that ask this topic