Difficulty: Medium
Correct Answer: 30
Explanation:
Introduction / Context:
This question checks understanding of the conditional (ternary) operator ?: in C#. The operator evaluates a Boolean expression and returns one of two results.
Given Data / Assumptions:
Concept / Approach:
Nested ternary operations must be carefully evaluated respecting parentheses and operator precedence. First the outer condition is tested, then the inner one.
Step-by-Step Solution:
Verification / Alternative check:
Compiling and running the code outputs 30, confirming correctness.
Why Other Options Are Wrong:
10 and 20 are wrong because conditions did not direct evaluation there. Compile error is wrong because syntax is valid.
Common Pitfalls:
Forgetting parentheses or misunderstanding evaluation order in nested ternary operators.
Final Answer:
30
Discussion & Comments