ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
int a = 2, b = 3, c = 4;
printf("%d %d %d", a + b * c % 5 - -a, a < b < c, c > b > a);
  1. A. 5 1 1
  2. B. 6 1 1
  3. C. 6 1 0
  4. D. 3 1 0

Correct answer: C. 6 1 0

* and % share a precedence level and group left to right: (3 * 4) % 5 = 2, so 2 + 2 − (−2) = 6. Relational operators also group left to right and yield 0 or 1: a < b < c is (2 < 3) < 4 → 1 < 4 → 1, but c > b > a is (4 > 3) > 2 → 1 > 2 → 0. C does not chain comparisons the way mathematics does.

More C Programming questions

Exams that ask this topic