Logical Operators
Last Updated: Jan 2026
Logical operators are used to combine or invert conditions — they return true or false depending on logic results.
🗂 List of Logical Operators
✏ Mini Example
int a = 10;
int b = 5;
int c = 7;
printf("%d\n", (a > b) && (a > c)); // true (both true)
printf("%d\n", (a > b) || (a < c)); // true (one is true)
printf("%d\n", !(a > b)); // false (reverse)
💡 Quick Practice
- Check if both conditions x > 5 and y < 10 are true.
- Print "Welcome" if userName exists, using &&.
- Use || to set a default name when user input is empty.
- Exercises Set
