+ 1

Why x has only changed?

int x=1,y=1,z=1; cout<<(++x||++y&&++z); cout<<x<<y<<z; Output:1211

21st Jul 2020, 2:28 AM
Aniket Chaudhary
Aniket Chaudhary - avatar
2 Respuestas
+ 2
Because a good compiler stops its work, if nothing else is to do. If you change the expression from OR to AND, then all your variables will be increased. If the first condition is true, every following OR condition is completely irrelevant for the program. Due to that, it's not evaluated.
21st Jul 2020, 2:36 AM
Sandra Meyer
Sandra Meyer - avatar
+ 1
Thanks Sandra Meyer..
21st Jul 2020, 3:34 AM
Aniket Chaudhary
Aniket Chaudhary - avatar