An operator is a symbol that tells C to perform an operation on one or more values. The values it works on are called operands.
Types of operators
Arithmetic: +, -, *, / and % perform numeric calculations.
Relational: <, <=, >, >=, == and != compare values.
Logical: &&, || and ! combine or reverse conditions.
Bitwise: &, |, ^, ~, << and >> work with the bits of integers.
Assignment: = stores a value; += and similar forms combine calculation and assignment.
Increment and decrement: ++ adds one and -- subtracts one.
Conditional: ?: selects one of two expressions based on a condition.
Classification by number of operands
Unary: Works on one operand, such as -x or !ready.
Binary: Works on two operands, such as a + b.
Ternary: Works with three operands. The conditional operator is written condition ? value1 : value2.
Example
In total = price * quantity;, * multiplies price and quantity, and = stores the result in total. In age >= 18 && has_id, >= compares age with 18 and && combines the two conditions.
Important points
Do not confuse = with ==: one assigns and the other compares. Likewise & is bitwise AND, while && is logical AND. Parentheses can make grouping clear. Choose types and input values that make the operation valid.
Reference table
↔ Scroll horizontally on a small screen
Operator families
Family
Operators
Example
Arithmetic
+ − * / %
a + b
Relational and equality
< <= > >= == !=
score >= 40
Logical
&& || !
valid && ready
Bitwise
& | ^ ~ << >>
flags & mask
Conditional
?:
a > b ? a : b
Increment/decrement
++ --
++count
Assignment
= += -= *= /= %= and bitwise compound forms
total += value
Other useful operators
sizeof, casts, comma, address and indirection
sizeof(int)
Key points
An operand is the value or expression an operator acts on.
Operator purpose and operand count are two different classifications.