Operators in C | Logical operators

Logical Operators

The following table shows all the logical operators supported by C language. 

Logical Operator And (&&)

Operator Description
&& Called Logical AND operator. If both the operands are non-zero, then the condition becomes true.

Truth Table

condition 1 condition 2 result(condition1 && condition 2)
True (1) True(1) True (1)
True(1) False(0) False(0)
False(0) True(1) False(0)
False(0) False(0) False(0)

Logical Operator Or (||)

Operator Description
||  Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true.

Truth Table

condition 1 condition 2 result (condition 1 || condition 2)
True (1) True(1) True (1)
True(1) False(0) True(1)
False(0) True(1) True(1)
False(0) False(0) False(0)

Logical Operator Not (!)

Operator Description
! Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false.

Truth Table

Condition result (! condition)
True (1) False (0)
False (0) True (1)

Note:
If the value is Non zero it means True (1)
if the value is Zero it means False (0)