#
Give the output of the following expression (2)

a += a++ + ++a + --a + a-- ; when a = 7.

## Answers

Answered by

3

**Answer:**

**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.**

**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 ____calculating____ ____the ____final ____value ____of ____a ____is ____39____.__

__Hence__

__,__

__on__

__calculating__

__the__

__final__

__value__

__of__

__a__

__is__

__39__

__.__

Answered by

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