C provides three logical operators when we test more than one condition to make decisions. These are: && (meaning logical AND), || (meaning logical OR) and ! (meaning logical NOT).
Operator | Example | Meaning |
---|---|---|
&& | (Logical AND) | expression1 && expression2 true only if both expression1 and expression2 are true |
|| | (Logical OR) | expression1 || expression2 true if either expression1 or expression2 is true |
! | (Logical NOT) | !expression true if expression is false and vice versa |
The code is a C program that demonstrates the use of logical operators in C. Here is an explanation of each line of the code:
When you run this code, it will perform logical operations on variables and print the results in the console.
//Logical Operators #include<stdio.h> int main() { int a=32; //>=35 and(&&) <=100 printf("\nLogical And : %d",(a>=35 && a<=100)); printf("\nLogical Or : %d",(a>=35 || a<=100)); printf("\nLogical Not : %d",!(a>=35)); return 0; }To download raw file Click Here
Logical And : 0 Logical Or : 1 Logical Not : 1
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions