Computer Science, asked by svdy12345, 1 month ago

Find the value of a when int x=5,y=2 .
where initial value of a is 5
a + = (++x) + (--y) + x++ + y;​

Answers

Answered by himanshugate20
0

Answer:

Final value of a= 19

Explanation:

Pre increment/decrement operator(++ var) : first increment/decrement the value and then use it.

Post increment/decrement operator(++ var) : first use the value and the increment/decrement accordingly.

Given, a= 5, x=5,y=2;

a += (++x) + (--y) + x++ +y;

a = a + (++x) + (--y) + x++ +y;

a = 5 + (6) + (1) + (6) + 1;               // after this, x = 7 because of (x++)

So, a =19

x=7, y=1

Similar questions