Operators

Lesson 2 of 20

Meet the symbols that do the work: do math, compare values and combine true and false — one operator at a time.

The big picture

Operators: the verbs of C

Operators are tiny symbols with big jobs — arithmetic, comparison and logic, all squeezed between your values.

Arithmetic

+ - * / % do the math. Two hide traps: / drops the fraction between ints, % gives the remainder.

Relational

== != < > <= >= compare two values and produce 1 (true) or 0 (false).

Logical

&& is AND, || is OR, ! flips. They chain simple tests into bigger decisions.

Assignment

= stores a value. Its shortcuts += -= *= /= %= update a variable in one step.