Computer Applications
If x = 5
and y = 4
, what will be the output of the following code?
x += ++y - x-- + y++;
System.out.println("x = " + x);
System.out.println("y = " + y);
Java Operators
3 Likes
Answer
x = 10
y = 6
Reason — The given expression is evaluated as follows:
x += ++y - x-- + y++
x = x + (++y - x-- + y++) [x=5, y=4]
x = 5 + (5 - 5 + 5) [x=4, y=6]
x = 5 + 5
x = 10
and
y=6
Answered By
1 Like
Related Questions
if (a>b&&b>c) then largest number is:
- b
- c
- a
- wrong expression
Identify the operator that gets the highest precedence while evaluating the given expression:
a + b % c * d - e
- +
- %
- -
- *
Evaluate the following expression if the value of x=2, y=3 and z=1. v=x + --z + y++ + y
Evaluate the expression when x is 4:
x += x++ * ++x % 2;