Logical Operators
We say any expression that evaluates to zero is a FALSE logic condition and that evaluating to non-zero value is a TRUE condition. Logical operators are useful in combining one or more conditions. The following are the logical operators :
&& AND
|| OR
! NOT
The first two operators are binary, while the exclamation(!) is a unary operator. It is used to negate the condition.
e.g.
x<0 && y>10 evaluates to true if both conditions are
true
x < 0 || z = = 0 evaluates to true, if one of the
conditions is true
!(x == 0) evaluates to true if condition is false.
The unary negation operator (!) has a higher precedence amongst the these, followed by the and (&&) operator and then the or(||) operator, and are evaluated from left to right.