What will be the output of the following program snippet if X=5 an Y=10 ?
Y = (X >= Y)? ++X : ++Y;
Answers
Answered by
3
Answer:
The output for the question is 11, i.e.,
Y = 11
Step By Step Solution:
It's given that,
➡ X = 5
➡ Y = 10
Y = (X >= Y) ? ++X : ++Y;
This means,
if(X >= Y)
Y = ++X;
else
Y = ++Y
X>=Y
= 5 >=10
As 5>=10 is false, so,
➡ X>=Y is false.
So, if block will not execute. It means else block will execute.
➡ Y = ++Y
➡ Y = 11 (Pre-Increment)
Hence,
- Y = 11
- X = 5
Similar questions
English,
1 month ago
English,
1 month ago
Accountancy,
1 month ago
English,
3 months ago
CBSE BOARD XII,
3 months ago