ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
int x = 2, y = 3, z = 4;
int r = x + y == z || x * y == z + 2;
printf("%d", r);
  1. A. 0
  2. B. 2
  3. C. Compilation error
  4. D. 1

Correct answer: D. 1

Precedence: +,* bind before ==, which binds before ||. (x+y)==z is (5==4)=0. (x*y)==(z+2) is (6==6)=1. 0 || 1 = 1.

More C Programming questions

Exams that ask this topic