The Relational Operators in C are used to compare two variables, what if we want to compare more than one condition? Very simple, logical operators will do the trick for you.
The Logical operators are some of the C Programming Operator, which are used to combine two or more conditions and perform the logical operations using && (Logical AND), || (Logical OR) and ! (Logical NOT). Below table shows all the list of Logical Operators in C with examples.
|&&||logical AND||It will return true when both conditions are true||If (age > 18 && age <=35)|
|||||logical OR||It will returns true when at-least one of the condition is true||If (age > 35 || age < 60)|
|!||logical NOT||If the condition is true, logical NOT operator makes it false||If age = 18 then!( age = 18) returns false.|
Let us see the truth tables behind the logical operators in C Programming for better understanding
&& (LOGICAL AND)
|Condition 1||Condition 2||Condition 1 && Condition 2|
|| (LOGICAL OR)
|Condition 1||Condition 2||Condition 1 || Condition 2|
Thank You for Visiting Our Blog