0
Can someone please explain this code to me ?
I saw this code in the regular challenges I play and could not fathom the final output , so I wrote the code into the code playground to check if the output is correct , and it was. I don't understand how the values of y and z don't increment while on the contrary the value of x does. https://code.sololearn.com/c9TZEMq15U70/?ref=app
4 Answers
+ 4
Compiler precedence is (++x||(++y&&++z)) so since first is true no need to look at second.
+ 3
cout<<(++x||++y&&++z)<<endl;
because x is not 0 the expression is true so the other side of the or does not execute as it can't change the true already reached.
+ 2
Oh ! I need to go through C++ Operator Precedence once again ! Thank you so much @John !
+ 1
But @John , aren't the ++x || ++y supposed to be executed together ? Like { (++x || ++y)&&++z } ??