TopMyGrade

GCSE/Computer Science/AQA

CS2.3Arithmetic operations: addition, subtraction, multiplication, real division, integer division (DIV), modulus (MOD), exponentiation

Notes

Arithmetic operations

Programming languages support the standard arithmetic operations and a few extra integer-specific ones that are useful in algorithms.

The basic operations

OperationSymbolExampleResult
Addition+7 + 411
Subtraction7 − 43
Multiplication×7 × 428
Real division/7 / 23.5

These work on integers and reals. Real division returns a real number even when both operands are integers.

Integer division (DIV) and modulus (MOD)

Two extras are essential at GCSE.

  • DIV gives the integer quotient of a division (the whole-number part, throwing away the remainder).
  • MOD gives the remainder after integer division.

Examples:

ExpressionDIV resultMOD result
17 / 532
20 / 450
23 / 732
100 / 2540

In pseudocode: 17 DIV 5 = 3, 17 MOD 5 = 2.

Why DIV and MOD matter

A surprising amount of useful logic uses them:

  • Even or odd: n MOD 2 = 0 is true if n is even.
  • Divisibility: n MOD 7 = 0 is true if n is a multiple of 7.
  • Last digit: n MOD 10 returns the units digit of n.
  • Without last digit: n DIV 10 removes the units digit.
  • Convert seconds to mm:ss: total seconds → mins = total DIV 60, secs = total MOD 60.
  • Hour into 12-hour clock: ((h - 1) MOD 12) + 1.

Exponentiation

In AQA pseudocode, exponentiation is shown as x^y or x ** y depending on context.

SET areaCircle TO 3.14159 * radius^2

Most languages allow pow(x, y) as an alternative.

Operator precedence

Standard maths precedence applies (BIDMAS / BODMAS). When in doubt, use brackets:

SET result TO 2 + 3 * 4         -- 14, not 20
SET result TO (2 + 3) * 4       -- 20
SET result TO (a + b) DIV 2      -- average of a, b for integers

Real-vs-integer arithmetic

Be careful when mixing types. 10 / 4 returns 2.5 in real division but 10 DIV 4 returns 2. If your variable is an integer, real division might require explicit conversion.

SET avg TO (a + b) / 2          -- real
SET avg_int TO (a + b) DIV 2    -- integer (rounds down)

Worked exampleWorked examples

Example 1. Convert 200 seconds to minutes and seconds.

  • mins = 200 DIV 60 = 3
  • secs = 200 MOD 60 = 20
  • So 200 s = 3 min 20 s.

Example 2. Last 3 digits of an integer n.

  • n MOD 1000

Example 3. Test whether year is a leap year (simplified rule: divisible by 4):

  • IF year MOD 4 = 0 THEN ...

Common mistakesPitfalls

  1. Confusing DIV and MOD. DIV = quotient, MOD = remainder.
  2. Using / for integer division — gives a real result.
  3. Forgetting BIDMAS — a + b * c is not (a + b) * c.
  4. Negative MOD: -17 MOD 5 may give 3 or -2 depending on language. Best avoided in GCSE problems.
  5. Floating-point precision: 0.1 + 0.2 is not exactly 0.3 in real arithmetic — small rounding errors. (More relevant at A-Level.)

Try thisQuick check

A program needs to find the units digit of a 4-digit number n. Which operation gives it? n MOD 10.

To extract the tens digit? (n DIV 10) MOD 10.

To extract the hundreds digit? (n DIV 100) MOD 10.

AI-generated · claude-opus-4-7 · v3-deep-computer-science

Practice questions

Try each before peeking at the worked solution.

  1. Question 14 marks

    Evaluate DIV and MOD

    Evaluate (a) 23 DIV 4, (b) 23 MOD 4, (c) 50 DIV 8, (d) 50 MOD 8.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  2. Question 22 marks

    Even check

    Write a Boolean expression that evaluates to true when an integer n is even.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  3. Question 34 marks

    Time conversion

    Write pseudocode that takes a number of seconds (e.g. 200) and outputs it in the form "X min Y sec".

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  4. Question 42 marks

    Last digit

    A 5-digit integer is stored in variable n. Write a pseudocode expression that extracts the last digit (units).

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  5. Question 54 marks

    BIDMAS

    Evaluate, showing the order of operations:
    2 + 3 * 4 - 6 / 2

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  6. Question 63 marks

    Hundreds digit

    Show how to extract the hundreds digit from a 4-digit integer n. Example: if n = 4276, the answer should be 2.

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

  7. Question 74 marks

    Integer vs real division

    Predict the result and explain:
    (a) 7 / 2 (real division)
    (b) 7 DIV 2

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-deep-computer-science

Flashcards

CS2.3 — Arithmetic operations including DIV and MOD

12-card SR deck for AQA GCSE Computer Science topic CS2.3

12 cards · spaced repetition (SM-2)