Important Notice:

Course Content
Building IoT Applications (Chapter-4) M4-R5.1
About Lesson

Logical Operators.

            These operators are used to combine the results of two or more conditions. An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false. Logical operators are commonly used in decision making in C programming.

Operator

Meaning

Example

Return value

&&

Logical AND

(9>2)&&(17>2)

1

||

Logical OR

(9>2) || (17 = = 7)

1

!

Logical NOT

29!=29

0

       

 

Logical AND : If any one condition false the complete condition becomes false.

Truth Table

Op1

Op2

Op1 && Op2

true

true

true

true

false

false

false

true

false

false

false

false

 

Logical OR : If any one condition true the complete condition becomes true.

Truth Table

Op1

Op2

Op1 // Op2

true

true

true

true

false

true

false

true

true

false

false

false

 

Logical Not : This operator reverses the value of the expression it operates on i.e, it makes a true expression false and false expression true.

 

Op1

Op1 !

true

false

false

true

error: Content is protected !!