C Programming Language


Operator


Logical Operator :

The following table shows the logical operators:
Assume Boolean variables X holds true and variable Y holds false, then:

Operator Descriptions Example
&& Calling the Logical AND operator. If both the operands are not zero, then condition is true. (X && Y) is false.
|| Calling the Logical OR Operator. If any of the two operands is not zero, then condition is true.. (X || Y) is true.
! Calling the Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true, then Logical NOT operator will make false. !(X && Y) is true.
< (X < Y) is true.
Example :

Output :

Line 1 - Condition : true
Line 2 - Condition : true
Line 3 - Condition : false
Line 4 - Condition : true
Line 5 - y is either greater than or equal to y