1.

Int x= 4x+ = (x++) + (++x) + x;​

Answer»

OUTPUT = 17

x+ is equivalent to x = x +

So the GIVEN STATEMENT will be rewritten as:

x = x + (x++) + (++x) + x;

= 4 + 4 + 5 + 4

= 17

The value of x++ will be 4 because it is a post-increment i.e. its increment will be reflected in the next upcoming statement, after executing the current one.

In contrast, the value of ++x will be 5 because it is a pre-increment i.e. it will increment the given variable before executing the whole statement.



Discussion

No Comment Found