Computer Science, asked by pammysdp, 4 months ago

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

Answers

Answered by memanan03
1

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.

Similar questions