Computer Science, asked by 6698, 4 months ago

a-- + ++a + a--
find the output if a=20​

Answers

Answered by Delnababu
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 sudhanshukonte
2

Answer:

60

Explanation:

20+now updated to 19 but again updated to 20+again 20

=20+20+20

=60

Similar questions