ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
int a = 5, b = 2, c = 3;
int result = a > b > c;
printf("%d", result);
  1. A. 5
  2. B. 1
  3. C. 0
  4. D. Compilation error: chained comparisons are not allowed

Correct answer: C. 0

Unlike Python, C has no chained comparisons: `a > b > c` parses as `(a > b) > c`. (5 > 2) evaluates to 1 (true); then `1 > 3` is false, giving 0 — a common trap for programmers coming from Python.

More C Programming questions

Exams that ask this topic