Question 9
Back to Exercise
What is the type of the expression flag ? 1 : 2.0?
- A int
- B double Correct
- C It depends on flag
- D float
Correct Answer: Option B
The conditional operator has one type, worked out at compile time from both branches with the usual arithmetic conversions: int and double give double. So even when flag is true the result is 1.0.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!