ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
int x = 2, y = 3, z = 4;
int result = x + y * z - x / y;
printf("%d", result);
  1. A. 14
  2. B. 7
  3. C. 20
  4. D. 13

Correct answer: A. 14

Following standard precedence (* and / before +, -, left to right among equal-precedence operators): x + y*z - x/y = 2 + (3*4) - (2/3) = 2 + 12 - 0 (integer division 2/3 truncates to 0) = 14.

More C Programming questions

Exams that ask this topic