Ch 5 · Operators & Expressions · C++
Topic 5 of 13 in C++ — Complete Tutorial (Beginner) — 2 lessons.
Arithmetic Operators
Arithmetic operators perform calculations. They match the symbols from maths, plus the modulus % which gives the remainder. As in C, dividing two integers throws away the decimals — 7 / 2 is 3 — so make one value a double to get 3.5. The ++ and -- operators add or subtract one, used constantly in loops.
Comparison & Logical Operators
Comparison operators compare two values and produce a bool — true or false. Logical operators combine conditions: && (AND) needs both true, || (OR) needs at least one, and ! (NOT) flips a value. Together they build the conditions your program uses to make decisions. Unlike C, C++ has a real bool type that prints as 1/0.