a-- + ++a + a--
find the output if a=20
Answers
Answered by
3
The result of the statement depends on the compiler. Clang++ gives "warning: unsequenced modification and access to 'a'." But g++ follows the following procedure.
Follow the precedence:
1. Pre Increment (++a)
2. Addition (+)
3. Assignment (+=)
'++a' means 'a = a + 1'. So, 'a' is now 21. Then the addition a + 21 means 21 + 21 which is 42 but you didn't store the result in 'a' yet. So, 42 is in a temporary variable and the value of 'a' is 21. Now the last assignment part, 'a += 42'. which is 'a = a + 42'. The value of 'a' is 21 so, the result is 63.
Answered by
2
Answer:
60
Explanation:
20+now updated to 19 but again updated to 20+again 20
=20+20+20
=60
Similar questions
History,
2 months ago
Political Science,
2 months ago
Biology,
2 months ago
English,
4 months ago
Math,
4 months ago
Social Sciences,
10 months ago
Political Science,
10 months ago