Operators & Expressions
Learn arithmetic, comparison, and logical operators in C. This is a foundational concept in systems programming that professional developers rely on daily. The explanations below are written to be beginner-friendly while covering the depth and nuance that comes from real-world C experience. Take your time with each section and practice the examples
20 min•By Priygop Team•Last updated: Feb 2026
C Operators
C supports all standard arithmetic operators. The % operator gives the remainder of division. C also has increment (++) and decrement (--) operators. Comparison operators return 1 (true) or 0 (false) in C — there is no boolean type in C89 (use int or include stdbool.h).
Operators
- + - * / % — Arithmetic operators
- ++ — Increment (add 1): i++ or ++i
- -- — Decrement (subtract 1): i-- or --i
- == != > < >= <= — Comparison (return 1 or 0)
- && — Logical AND
- || — Logical OR
- ! — Logical NOT
- += -= *= /= — Compound assignment
Operators Example
Example
#include <stdio.h>
int main() {
int a = 10, b = 3;
printf("a + b = %d\n", a + b); // 13
printf("a - b = %d\n", a - b); // 7
printf("a * b = %d\n", a * b); // 30
printf("a / b = %d\n", a / b); // 3 (integer division)
printf("a %% b = %d\n", a % b); // 1 (remainder)
// Increment/Decrement
int count = 5;
count++;
printf("After count++: %d\n", count); // 6
count--;
printf("After count--: %d\n", count); // 5
// Comparison
printf("a > b: %d\n", a > b); // 1 (true)
printf("a == b: %d\n", a == b); // 0 (false)
return 0;
}Try It Yourself: Calculator
Try It Yourself: CalculatorC
C Editor
✓ ValidTab = 2 spaces
C|19 lines|524 chars|✓ Valid syntax
UTF-8