+ 10
Problem with a challenge question!!
Why is only the x incremented, and the y and the z not?? https://code.sololearn.com/cOc3EnZP166w/?ref=app
5 Answers
+ 8
i am just a beginner..but i think on "logical OR || since first is true whether second condition is true or false..it will be true..so it skipped y and z part..here x is pre incremented (++x) so value of x is 2..but y and z value becomes same i.e 1.
+ 8
Thank you, evaluating from left to right the expression (++x || ++y && ++z) because of short circuit evaluation only ++x is evaluated, it gives true to the logic operator OR and AND expressions!!
+ 6
check this code out the comments will tells u đ
https://code.sololearn.com/ciMCHtM5eAPe/?ref=app
+ 5
Try changing to && it will check 2nd condition and y and z value will be 2,2
+ 1
pre increment in cout statement usually behaves wierdly, its compiler dependent, try it in some other compiler, you will get a different answer