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.

All topics in C++ Beginner

  1. Introduction to Programming & C++
  2. Your First C++ Program
  3. Variables & Data Types
  4. Input & Output
  5. Operators & Expressions
  6. Conditional Statements
  7. Loops & Iterations
  8. Functions
  9. Vectors & Strings
  10. Classes & Objects
  11. Working with Classes
  12. Exception Handling
  13. Mini-Projects & Practice