C Operators
On this page (7sections)
Introduction
An operator is a symbol that tells the compiler to perform a mathematical or logical operation. C has a rich set of operators used in expressions, conditions and assignments.
Operators are grouped by the number of operands they take and the type of operation they perform. Each topic below links to a dedicated tutorial with syntax, example programs and sample output.
C Operator Categories
| Category | Operators | Tutorial |
|---|---|---|
| Arithmetic | +, -, *, /, % | Arithmetic Operators |
| Relational | ==, !=, <, >, <=, >= | Relational Operators |
| Logical | &&, ||, ! | Logical Operators |
| Assignment | =, +=, -=, *=, /=, %= | Assignment Operators |
| Unary | ++, --, +, - | Unary Operators |
| Conditional (Ternary) | ? : | Conditional or Ternary Operator |
| Bitwise | &, |, ^, ~, <<, >> | Bitwise Operators |
| Special | ,, (type) cast, sizeof, &, * | Special Operators in C |
Browse All Operator Tutorials
For the full list of operator example programs, visit the C Operators hub.
- Arithmetic Operator Example Program
- Relational Operators
- Logical Operators
- Assignment Operators
- Unary Operators
- Conditional or Ternary Operator
- Bitwise Operators
- Special Operators in C
Related C Controls Topics
Quick Example
#include <stdio.h>
int main(void) {
int a = 10, b = 3;
printf("Sum: %d\n", a + b); /* arithmetic */
printf("Equal? %d\n", a == b); /* relational */
printf("Both true? %d\n", a > 0 && b > 0); /* logical */
return 0;
}
Sample Output
Sum: 13
Equal? 0
Both true? 1
Related Pages
Continue learning with these related tutorials and programs:
- C Tutorials — Browse all C Tutorials.
- If Else Statement in C — Tutorial — if, if-else and nested conditions.
- Loop Control Statements — More in c controls.
- C Data Input and Data Output — More in c controls.