ProgrammingHardTCS NQT · Infosys

int a = 1 ? 2 : 3 ? 4 : 5; What is a?

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

Correct answer: D. 2

The conditional operator groups to the right, so the expression is 1 ? 2 : (3 ? 4 : 5). The condition 1 is true, which selects 2.

More C Programming questions

Exams that ask this topic