If a=5 Find - a++ + ++a + a++
Answers
Answered by
5
- The final value of a is 19.
The initial value of 'a' is 5.
After evaluating the expression,
> a = a++ + ++a + a++
> a = 5 + ++a + a++ [a remains 5, post-increment]
> a = 5 + ++a + a++ [a becomes 6]
> a = 5 + 7 + a++ [a becomes 7, pre-increment]
> a = 12 + a++
> a = 12 + 7 [a becomes 8 after post-increment]
> a = 19
⊕ So, result obtained = 19.
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
Answered by
2
Answer:
Answer : a = 3
Explanation:
I hope it's helpful
Similar questions