Ch 5 · Operators & Expressions · C

Topic 5 of 13 in C — Complete Tutorial (Beginner) — 3 lessons.

Arithmetic Operators

Arithmetic operators perform calculations on numbers. They mostly match the symbols from maths class. The modulus operator % gives the remainder after division — 17 % 5 is 2. A crucial rule in C: dividing two integers gives an integer result with the remainder thrown away, so 7 / 2 is 3, not 3.5. To get a decimal, at least one value must be a float or double. The ++ and -- operators add or subtract one.

Comparison & Logical Operators

Comparison operators compare two values and give either 1 (true) or 0 (false) — C has no separate boolean type by default; it uses integers, where 0 means false and any non-zero value means true. Logical operators combine conditions: && (AND) needs both true, || (OR) needs at least one, and ! (NOT) flips a value. These build the conditions your program uses to make decisions.

Assignment Operators

Assignment operators are shorthand ways to update a variable using its current value. Writing score += 10 means score = score + 10. These compact forms — +=, -=, *=, /=, %= — appear constantly whenever a value changes step by step, such as counting up a score or reducing a countdown. They save typing and make the intent clear.

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. Arrays
  10. Strings
  11. Pointers
  12. Structures
  13. Mini-Projects & Practice