Operators, Knowledge Organiser

Knowledge Organiser: Operators

Key Terms

  • Arithmetic operator: Performs a mathematical calculation (+, -, *, /, DIV, MOD)
  • Comparison operator: Compares two values and returns true or false (==, !=, <, >, <=, >=)
  • Logical operator: Combines boolean conditions (AND, OR, NOT)
  • DIV: Integer division — divides and discards the remainder (e.g. 17 DIV 5 = 3)
  • MOD: Modulus — returns only the remainder (e.g. 17 MOD 5 = 2)

Must-Know Facts

  • / gives a real result; DIV gives an integer result (no remainder)
  • MOD is used to check if a number is even: number MOD 2 == 0
  • Use == for comparison; = is for assignment
  • AND: both conditions must be true; OR: at least one must be true; NOT: inverts the value
  • 5 DIV 2 = 2 and 5 MOD 2 = 1 (together they give the full division result)

Key Concepts

  • Check even/odd: if number MOD 2 == 0 then (even)
  • Get last digit of a number: number MOD 10
  • Cycle through 0–9: counter MOD 10
  • Combine conditions: if age >= 18 AND hasID == true then

Common Mistakes

  • Confusing DIV and MOD: DIV gives the whole number part of a division (quotient); MOD gives the remainder — 17 DIV 5 = 3, 17 MOD 5 = 2
  • Using = instead of == in conditions: = is assignment (gives a value); == is comparison (tests if equal) — using the wrong one is one of the most frequent pseudocode errors
  • Confusing / and DIV: / (division) can give a real/decimal result; DIV always gives an integer result by discarding the remainder
  • Mixing up AND and OR: AND requires BOTH conditions to be true; OR requires at least ONE — confusing them produces logic that accepts or rejects the wrong values
  • Forgetting NOT inverts a boolean: NOT true gives false and vice versa — useful for toggling flags or reversing conditions

PrepWise is a trading name of A3M Quality Solutions Limited, registered in England and Wales, company number 14959172. Registered office: 202 Stroud Road, Gloucester, GL1 5LA. ICO registration ZC267069.