Multiple choice

Which of the following is/are conditional operator(s)?

  1. Double Ampersand (&&)

  2. Double Pipeline (||)

  3. Question mark and colon (? :)

  4. Question mark (?)

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The conditional (ternary) operator in C++ is ?: (question mark and colon). It's the only operator that takes three operands: condition ? value_if_true : value_if_false. For example: max = (a > b) ? a : b;. Double ampersand (&&) is logical AND, double pipeline (||) is logical OR, and a single question mark (?) alone is not a valid operator.