Multiple choice

In the under given expression flag = (i < 10) ? 0 : 100 if the value of 'i' is 12, then the result is

  1. 0

  2. 10

  3. 100

  4. 12

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

The ternary operator (?:) evaluates the condition. If true, it returns the first value; if false, it returns the second. Here (12 < 10) is false, so flag gets the value after the colon, which is 100.