Logical Operators in C Programming
Logical Operators in C Programming
Introduction to Logical Operators
Logical operators in C programming are used to combine multiple conditions. They help in making decisions based on more than one condition.
Logical operators are commonly used in if statements, loops, and complex conditions.
Types of Logical Operators
Common Logical Operators
&&Logical AND||Logical OR!Logical NOT
Logical AND (&&) Operator
The AND operator returns true (1) only if both conditions are true.
Example
int main() {
int a = 10, b = 5;
if(a > 5 && b < 10) {
printf(“Both conditions are true”);
}
return 0;
}
Logical OR (||) Operator
The OR operator returns true (1) if at least one condition is true.
Example
int main() {
int a = 2, b = 5;
if(a > 5 || b < 10) {
printf(“At least one condition is true”);
}
return 0;
}
Logical NOT (!) Operator
The NOT operator reverses the result of a condition.
Example
int main() {
int a = 5;
if(!(a > 10)) {
printf(“Condition is false, so NOT makes it true”);
}
return 0;
}
Truth Table of Logical Operators
AND (&&)
- True && True → True
- True && False → False
- False && True → False
- False && False → False
OR (||)
- True || False → True
- False || False → False
NOT (!)
- !True → False
- !False → True
Using Logical Operators in Real Programs
int main() {
int age = 20;
if(age >= 18 && age <= 60) {
printf(“Eligible for job”);
}
return 0;
}
Why Logical Operators are Important
Key Benefits
- Combine multiple conditions
- Improve decision-making
- Used in real-world logic
- Essential for control flow
Start Learning C Programming
Practice logical operators to build strong problem-solving skills in C programming.
Summary
Logical operators in C programming are used to combine conditions. They include AND, OR, and NOT operators and are essential for decision-making.
FAQs
What are logical operators in C programming?
Logical operators are used to combine multiple conditions.
What does && mean in C?
It means logical AND and returns true if both conditions are true.
What does || mean in C?
It means logical OR and returns true if at least one condition is true.
What does ! mean in C?
It is logical NOT and reverses the condition.



