Evaluate
( X + Y > Z ) ? ( ++ X - Y ) : ( - -Z + ++ Y )
where X = 8 , Y = 10 , Z= 8
I need steps !!!
The answer is -1
C++ || CoMpUtEr sCiEnCe || ClAsS xI
Answers
Answered by
2
X=8
Y=10
Z=8
((8+10)>8) ? (++8 - 10) : (--8+ ++10)
(18>8) ...................... {TRUE}
∴ (9-10) = -1
The output will be
-1
BrainlyHulk:
Thank You Bro
Answered by
2
Ternary operator:
(Condition) ? (if_true) ? (if_false)
Sample Program:
x = 8, y = 10, z = 8;
(x + y > z) ?? (++x - y) : (--z + ++y)
Explanation:
(8 + 10 > 8) ?? (9 - 10) : (7 + 11)
Here, (8 + 10 > 8 = 18 > 8) is true, So the first statement is executed i.e 9 - 10 = -1. If the condition is false, the 2nd statement would be executed.
Therefore, the output will be 9 - 10 = -1.
Hope it helps!
Similar questions