ProgrammingHardTCS NQT · Infosys

int x = 5; printf("%d", x > 3 ? x - 3 : x + 3); What is printed?

  1. A. 8
  2. B. 3
  3. C. 5
  4. D. 2

Correct answer: D. 2

x > 3 is true, so the conditional yields x - 3 = 2. The conditional operator has lower precedence than comparison but higher than assignment.

More C Programming questions

Exams that ask this topic