Correct option is C
The program uses nested
ternary operators to evaluate conditions step by step:
1. (a > b) checks if 5 > 10, which is
false.
2. Since the first condition is false, the second part of the ternary operator is executed: ((a > c) ? a : c).
3. (a > c) checks if 5 > 15, which is also
false.
4. Thus, the value of c, which is
15, is assigned to result.
Finally, the program prints
15.
Important Key Points:
1. Nested ternary operators are evaluated from left to right, based on their conditions.
2. The
ternary operator ensures concise code but can become hard to read when nested.
3. Debugging ternary operations can be simplified by breaking them into smaller expressions.
Knowledge Booster:
·
Condition 1: (a > b) evaluates as
false, so the second branch is executed.
·
Condition 2: (a > c) evaluates as
false, so the value of c is selected.
·
Result: 15 is printed.