Logical Operators in C

In all programming languages you will find logical operators. Logical operators are used to combine conditional statements. There are three logical operators in C programming language.

Now, let’s see the logical operators in C:

Operator Description Example
&& Returns True if both statements are true x < 5 && y < 10
| Returns True if one of the statements is true x < 5 | x < 4
! Returns False if the result is true !(x < 5 && y < 10)

C program code with logical operators:

#include <stdio.h>
void main()
     int x=5,y=6;
     if(x<=5 && y<=5)
         printf("inputs are ok");
         printf("inputs are not ok");


inputs are not ok

Click Operators in C to know other operators in C programming language.

In this tutorial, I have shown logical operators in C. Hope you have enjoyed the tutorial. If you want to get updated, like my facebook page http://www.facebook.com/freetechtrainer and stay connected.

Add a Comment