+ 1

Why the result is -1 for the below operation?

int a = 1; printf("%d", (--a + a++ + a++ + --a)); Can anyone please explain how to apply stack concept for this?

13th Apr 2019, 8:47 AM
sbkrish
sbkrish - avatar
3 Antworten
+ 3
Actually it depends on the compiler. Multiple shortcut statements in one row lead to unexpected behavior.
13th Apr 2019, 9:08 AM
Matthias
Matthias - avatar
+ 1
according the solo compiler the result of this experience is "3" . I think it make sence , because there is more operation '+' and postincrement is done
30th Apr 2019, 12:07 AM
electron
electron - avatar
0
sbkrish What's the original value of int a?
13th Apr 2019, 9:00 AM
Dlite
Dlite - avatar