asked by gokulavaasan42004, 10 days ago

# Give the output of the following expression (2)a += a++ + ++a + --a + a-- ; when a = 7.​

3

Given, a=7.

a+=a++ + ++a + --a + a--;

>>>a=a+(a++ + ++a + --a + a--);

>>>a= 7+(7+9+8+8) //now a's value is 7

>>>a=7+32

>>>a=39.

Note:-

• In this question there is postfix(a++ or a--) and prefix(++a or --a) increment
• Postfix increment means first calculate then increase the value.

• that's why in the above solution a remains 7 even after a++ but as soon as it reaches ++a, a becoms 8
• Prefix increment is just opposite of postfix increment, it means first increase then calculate.

• given in above solution, when control reaches ++a, the current value of a is 8. As said, prefix means first increase then calculate, the value of a first increases to 9 , then the control moves further.

### Hence,on calculatingthe final value of a is 39.

2

After Execution:

a = 39

Explanation:

> a += a++ + ++a + --a + a--, a = 7,

> a += 7 + 9 + 8 + 8

> a += 16 + 16

> a = 7 + 32

> a = 39

Similar questions
Political Science, 5 days ago
Math, 5 days ago
Math, 5 days ago
Math, 10 days ago
History, 10 days ago
Math, 6 months ago
English, 6 months ago
Math, 6 months ago