# Lesson 3.11. Logical operators

In lesson 3.5, we studied bitwise logical operators. The logical operations were then applied bit by bit. The logical operators studied in this course work according to the following rule:

• An operand is considered false if its value is equal to zero ;
• otherwise, it is true.

Here are some examples:

• `0` is faux
• `15` is true
• `12.5` is true
• `3<2` is false
• `'r'` is true
• ...

There are three logical operators:

Operator Name Type
`&&` logical AND binary
`||` logical OR binary
`!` logical NOT unary

As for the comparison operators, these operators can only return 0 or 1. The returned value is always of integer type (`int`).

These operators are mostly used to combine comparisons:

``````if (a<5 && a>10)
...``````

## Quiz

For a logical operator, the value `-5` is considered as ....

What should be the type of the variable `x`?

``x = 1 || 0;``

What is the bitwise logical operator AND?

What does the following program display?

``printf ("%d", 1565 || 0);``

What does the following program display?

``printf ("%d", (12 || 0) && 127);``

How to test if `p` is between 0 and 100 inclusive?

What is the equivalent instruction?

``x = !(a<b);``