Which combination of the integer variables and makes the variable get the value in the following expression?
View worked solution
Answer: A
The given expression uses nested ternary operators:
Let's analyze the logic of this expression step-by-step:
- If is true:
The expression evaluates to
(x > z) ? x : z, which returns the maximum of and . Since , this effectively returns the maximum of all three variables, . - If is false (i.e., ):
The expression evaluates to
(y > z) ? y : z, which returns the maximum of and . Since , this also returns the maximum of all three variables, .
Thus, the expression simplifies to finding the maximum of the three variables:
We want . Let's evaluate the options to find which set of values has a maximum of :
- Option A: . (Correct)
- Option B: .
- Option C: .
- Option D: .
Free practice · Your answers on this page are not saved.
