# C - Logical Operators

### Logical Operators

This is used to check the logical relationship between two expressions. After checking the conditions, it provides logical true (non-zero value) or false (zero value) status. Here the operands can be constants, variable and expressions.

Operator      Name      Description      Example
&& Logical AND if both conditions are true, then it returns true5>3 &&5<10 is true
| |Logical ORif any one of two conditions is true, then it returns true5<3 | | 5<10 is true
! Logical NOTif the conditions is false, then it returns true!(5>3) is false

### Example

Following is an example C Program using Logical Operators.

```#include <stdio.h>
#include <conio.h>

int main()
{
int a=5;
int b=3;

if((a>3)&&(a<10)){
printf("The Logical AND Expression is True\n");
} else{
printf("The Logical AND Expression is False\n ");
}

if((b>a) || (b<10)){
printf("The Logical OR Expression is True \n ");
} else{
printf("The Logical OR Expression is False \n ");
}

if(!(a>b)){
printf("The Logical NOT Expression is True \n ");
} else{
printf("The Logical NOT Expression is False \n");
}
return(0);
}
```

### Output

```The Logical AND Expression is True
The Logical OR Expression is True
The Logical NOT Expression is False
```

# C - Logical Operators

### Logical Operators

This is used to check the logical relationship between two expressions. After checking the conditions, it provides logical true (non-zero value) or false (zero value) status. Here the operands can be constants, variable and expressions.

Operator      Name      Description      Example
&& Logical AND if both conditions are true, then it returns true5>3 &&5<10 is true
| |Logical ORif any one of two conditions is true, then it returns true5<3 | | 5<10 is true
! Logical NOTif the conditions is false, then it returns true!(5>3) is false

### Example

Following is an example C Program using Logical Operators.

```#include <stdio.h>
#include <conio.h>

int main()
{
int a=5;
int b=3;

if((a>3)&&(a<10)){
printf("The Logical AND Expression is True\n");
} else{
printf("The Logical AND Expression is False\n ");
}

if((b>a) || (b<10)){
printf("The Logical OR Expression is True \n ");
} else{
printf("The Logical OR Expression is False \n ");
}

if(!(a>b)){
printf("The Logical NOT Expression is True \n ");
} else{
printf("The Logical NOT Expression is False \n");
}
return(0);
}
```

### Output

```The Logical AND Expression is True
The Logical OR Expression is True
The Logical NOT Expression is False
```