if a=8 find the value of a= a++ + ++a
please answer fast
Answers
Answered by
4
- The final value of a is - 18.
Given:
> a = 8
On evaluating the expression:
> a = a++ + ++a
> a = 8 + ++a [a remains same, post-increment]
> a = 8 + ++a [a becomes 9]
> a = 8 + 10 [a becomes 10, pre-increment]
> a = 18
⊕ Hence, the final value of a is 18.n
There are two types of increment/decrement operations.
- Post increment/decrement.
- Pre increment/decrement.
Post Increment/Decrement – Here, operation takes place first and then the value is incremented/decremented.
Example –
> int a = 2;
> int b = a++;
> b = 2
Now, a = 3.
Pre Increment/Decrement – Here, value is first increment/decrement and then the operation is carried out.
Example –
> int a = 2;
> int b = ++a;
> b = 3
Also, a = 3
anindyaadhikari13:
Thanks for the brainliest!
Similar questions