+ 3
Can someone explain its output to me? Output: 1211
#include <iostream> using namespace std; int main() { int x=1, y=1, z=1; cout<<(++x||++y&&++z); cout<<x<<y<<z; return 0; } https://code.sololearn.com/cPcTxLyQDF8O/?ref=app
4 odpowiedzi
+ 4
First cout is true, so it prints a '1'.
To calculate the result of the first cout it only has to execute ++x. So x is now 2. Because ++y and ++z are never executed they remain 1.
If you replace the || in the first cout by a &&, you get a different result.
+ 4
Okay, I got it. Thank u for the answer