Logical Operators in C Programming
- Mohd Taha
- 6 days ago
- 1 min read
Logical operators in C are used to return a boolean value: true (1) or false (0).They are most commonly used in conditional statements (if, while, for) to control the flow of a program based on certain conditions.
In C, there are three primary logical operators:
Logical OR (||)
Logical AND (&&)
Logical NOT (!)
Let’s discuss each in detail.
1. Logical OR (||)
The logical OR operator returns true (1) if at least one condition is true. It returns false (0) only when all conditions are false.
Truth Table for OR

2. Logical AND (&&)
The logical AND operator returns true (1) only when all conditions are true.If any condition is false, the result will be false.

3. Logical NOT (!)
The logical NOT operator works like an inverter.It reverses the boolean value of an expression:
· If the condition is true (1), ! makes it false (0).
· If the condition is false (0), ! makes it true (1).
Truth Table for NOT

Example: Leap Year Checker
Here’s a simple program that uses logical operators to check whether a given year is a leap year or not.

Conclusion
Logical operators are essential in C programming.They help us combine conditions, simplify decisions, and make our programs more efficient.
I hope you enjoyed this blog! 🚀If you found it useful, please share it with your friends and anyone interested in learning C programming.
Comments