Computer Science, asked by ashwinilakhan6, 9 months ago

If int x=15; y=20; what will be the value of x after executing the following statement x=(x<y) ? (y+x) : (y-x);

5

15

25

35​

Answers

Answered by nandan2004
5

Answer:

The answer is 35.

Explanation:

x = 15, y = 20;

x = (x<y)?(y+x):(y-x);

//since x < y

(y+x) will be executed

so the answer is 35

Answered by ishwaryam062001
0

Answer:

The value of x after executing the given statement is 35.

Explanation:

The given declaration is a ternary operator announcement that entails the conditional operator "?". The ordinary structure of the ternary operator is as follows:

(condition) ? (expression1) : (expression2);

When the following statement is carried out: x=(x<y) ? ( y+x) : ( y-x);

The initial condition to be evaluated is xy. The condition holds true because y=20 and x=15.

Therefore,

         x will be given the value of the expression (y+x),

        i.e., x=20+15=35.

Here, if the circumstance is true, then the fee of expression1 will be assigned to the variable on the left-hand facet of the operator. Otherwise, the fee of expression2 will be assigned.

In this case, the circumstance is (x < y), where x=15 and y=20. As x is less than y, the condition is true. Therefore, the value of the expression (y+x) will be assigned to x.

So, x=(y+x)=(20+15)=35.

Hence, the value of x after executing the given statement is 35.

For more such related questions : https://brainly.in/question/55024814

#SPJ2

Similar questions