 ## C Logical Operators

Many times in C programming we need to generate logical expressions by combining two or more expressions. This is possible only through C logical operators. The combination of expressions/conditions along with the logical operator is called the “Logical Expression“. The value of a logical expression will be either true (1) or false (0). Whatever expressions are combined with logical operators to generate logical expressions, also called logical operands. These logical operands can be a variable, a constant, or an expression in itself. Logical operators are also called the “Boolean operators”. C Supports three logical operators. These C logical operators are shown below.

Here the C logical operators “Logical AND” and “Logical OR” are the binary operators while the “Logical NOT” is a unary operator. In C programming, if any condition returns a nonzero value, then that condition is always considered to be true. Otherwise, the condition will always be false.

### Logical AND Operator

If both expressions/conditions that have been combined through this operator are true, then the value of the Logical Expression will also be true. Otherwise, the value of the Logical Expression will be false.

Let u and v are two variables with their respective values as u=2, v=5. Now the “AND” logical operator will work like:

### Logical OR Operator

If both expressions/conditions that have been combined through this operator are false, then the value of the Logical Expression will always be false. Otherwise, the value of the Logical Expression will be true.

Let u and v are two variables with their respective values as u=2, v=5. Now the “OR” logical operator will work like:

### Logical NOT Operator

It is a Unary operator and it negates the value of the expression. if the value of the expression is true (1), then it makes it false (0). Otherwise, it produces the true (1) value, if the given value of the expression is false (0).

Let u and v are two variables with their respective values as u=2, v=5. Now the “NOT” logical operator will work like:

```Example:
#include<stdio.h>
main()
{
int u=5, v=2;
if(u>v && u!=0)
{
printf("Hurray both conditions are true\n");
}
if(v>u || v!=7)
{
printf("Oh great one condition is true\n");
}
if(!(u!=v && v>7))
{
printf("The final result is True indeed\n");
}
}
Output:
Hurray both conditions are true
Oh great one condition is true
The final result is True indeed
```

In this tutorial, we learned about C logical operators and now in the next tutorial we will learn about the “conditional operators in C programming”.