Logical operators

Before going any further, let's learn about a few logical operators. There are only three types of logical operators in C. They are, AND, OR, and NOT. All three operators cover any logical operation. These operators help to remove complexities and shorten the code. Let's learn their symbols first:

Name

Symbol

Meaning

AND

&&

This means, if all the conditions are true, then the condition is true.

OR

||

This means, if any of the conditions are true, then the condition is true.

NOT

!

This operator reverses the condition.

Now we will learn about the operators in detail.

AND operator

The AND operator means if all the conditions fulfill the condition, the condition is true.

Let's look at an example.

Suppose, ...

Get Learning C for Arduino now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.