int x = 1 , y = 1 , z = 1 ;
Now check these lines of code :-
cout << (++x || ++y)<<endl; //Output 1
cout << x <<" " << y; // now x = 2 and y = 1 . Why 'y' is not incremented ?
again values are initialized to 1
cout <<(++x && ++y )<<endl; //Output 1
cout << x <<" " << y; //now x = 2 and y = 2 . Why 'y' is incremented ?
again values are initialized to 1
cout << (++x ||++y && ++z )<<endl; //Output 1
cout << x<<" "<< y<<" "<<z ; //now x = 2 , y = 1 , z = 1.Why these outputs?
Can some one explain me how compiler reads these codes ? I read about the Precedence order but I can't figure out how compiler works on these types of code.Even a Small help will be appreciated!