Computer Science, asked by ishashaw033, 3 months ago

What will be the output of the following program snippet if X=5 an Y=10 ?
Y = (X >= Y)? ++X : ++Y;

Answers

Answered by anindyaadhikari13
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,

  1. Y = 11
  2. X = 5
Similar questions