**Conditional Operator Precedence** What is the decimal value of res ? in…
**Conditional Operator Precedence** What is the decimal value of res ? integer res; initial begin res = 1 ? 2 : 0 ? 3 : 4; end
- 3
- 4
- 2
- 0
Correct answer
C. 2
Explanation
The ternary operator ?: is right-associative: 1 ? 2 : (0 ? 3 : 4) . Because the first condition evaluates to 1 (True), the expression evaluates immediately to 2 .