ProgrammingHardWipro · Cognizant pattern

What is printed?

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

Correct answer: D. 1

Parses as `(x < y) < z` = `(1 < 2) < 3` = `1 < 3` = 1 (true) — again, not a mathematical chained comparison, just two independent < operations evaluated left to right.

More C Programming questions

Exams that ask this topic