+ 3

In C++ is it correct to conclude when first statement in 'if' with OR operation returns true, the rest is disregarded?

x = 3, y = 2; if(++x>0 || ++y>2)

12th Aug 2019, 4:40 AM
david chongo
david chongo - avatar
3 Answers
+ 4
In OR operator when first condition is satisfied then the complier does not test the second condition
12th Aug 2019, 5:19 AM
Sami
Sami - avatar
+ 4
In case if first condition isn't satisfied, then the compiler move on to check next condition otherwise as stated by Sami
12th Aug 2019, 8:45 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 1
Yes, as soon as one of the conditions is fulfilled, the operator returns true.
12th Aug 2019, 6:38 AM
Paul Grasser
Paul Grasser - avatar