+ 1
Please help, explain me how output is 3 .. not 4?
int main() { int a=0; a=a++ + a++ - a++ + ++a; printf("%d",a); return 0; }
3 Answers
+ 2
Your program sequence point issue so It is undefined by standards. You may get different answer in different compilers...
Read the warnings, it may evaluated from right to left or left to right.. So you get different values...
a = a++ + a++ - a++ + ++a;
Edit : @c Lover
https://www.sololearn.com/Discuss/2223222/?ref=app
0
According to BODMAS addition will be done first after that only subraction right?
0
C Lover The result of that expression is undefined in the standard since you're trying to read from and modify the same variable between two consecutive sequence points.(Or in the same expression)
Just as Jayakrishnađźđł has said,the result might vary from compiler to compiler