Give the output of the following statements when they are executed.
(i) int c = (5>6)?5*6 : 5+6;
Answers
Answered by
2
Answer:
11
Explanation:
The conditional operator is on the form
Variable = Expression1 ? Expression2 : Expression3
Expression1 is the condition to be evaluated. If the condition(Expression1) is True then Expression2 will be executed and the result will be returned. Otherwise, if the condition(Expression1) is false then Expression3 will be executed and the result will be returned.
Hence,
int c = (5>6)?5*6 : 5+6; will give the out as sum of 5 and 6= 11
Similar questions