Home » C Programming » Logical Operators in C Programming

Logical Operators in C Programming

There are three logical operators in C language. Assume variable A and B holds 1 and 0 respectively then –

Operator Description Example
&&  AND operator (the condition becomes true if both the operands are non-zero) (A && B) is false.
||  OR Operator (the condition becomes true if any of the two operands is non-zero) (A || B) is true.
!  NOT Operator (this operator reverse the logical state of operand. For example: If condition is true, then NOT operator will make it false) !(A && B) is true.

Example: Check both numbers are greater the 10 or not

Output

Example: Check both numbers are greater the 10 or not. Also check any one number is greater then 10 or not

Output

Please follow and like us:
error