GGCSE Revision Hub

3.2.3 Arithmetic operations in a programming language

AQA Computer Science 8525Topic 3.2 — ProgrammingFoundation & Higher

This is the longest topic in the specification and the one that carries most of the Paper 1 marks. It covers the statements every program is built from, the operators that do the work, the structures that hold data, and the discipline that makes code safe to rely on. Two of the specification's supported languages are Python and C#, so the examples here use Python-style syntax with the AQA pseudo-code where the specification demands it. Learn this as something you write, not something you memorise.

What you need to know

The five operations

Be familiar with and be able to use addition, subtraction, multiplication, real division and integer division including remainders. Addition, subtraction and multiplication behave the way you would expect. The division is where the care is needed, because real division and integer division are genuinely different operations and produce different answers for the same numbers.

Key fact: Addition, subtraction, multiplication, real division and integer division with remainders.

Real division

Real division keeps the fractional part, so 11 / 2 is 5.5. It only works properly when the numbers involved are stored as reals. If you want a whole number from real division you have to ask for it, for example with INT() or by using integer division in the first place.

Key fact: Real division keeps the fraction: 11 / 2 is 5.5.

Integer division

Integer division returns only the integer quotient — the whole number part of the answer, with the fractional part discarded. 11 DIV 2 is 5, not 5.5. The important caveat is that the integer quotient and the remainder are usually a two stage process: you calculate the division first and then the remainder, and a program that wants both needs both.

Key fact: Integer division gives the integer quotient only: 11 DIV 2 is 5.

Remainders

The remainder is what is left over after the division. 11 MOD 2 is 1, because 2 goes into 11 five times and one is left over. Remainders are used in real programs for checking whether a number is even or odd, for cycling through days of the week or months of the year, and for wrapping a value back into a range.

Key fact: 11 MOD 2 is 1 — the remainder after the division.

The worked example

The specification gives the example 11 / 2 and says it generates two values: integer division, 11 DIV 2 = 5, and remainder, 11 MOD 2 = 1. Together these two values can reconstruct the original division, because 5 × 2 + 1 = 11. Learn this example — if you remember one calculation from this topic, make it this one.

Key fact: 11 DIV 2 = 5 and 11 MOD 2 = 1, and 5 x 2 + 1 = 11.

Division by zero

Integer division by zero is an error in every language, and real division by zero is an error too. It is worth mentioning in a robustness answer, because a program that takes a number from the user and divides by it must check for zero before dividing. That is data validation, which is covered in 3.2.11.

Key fact: Dividing by zero is an error, so validate the divisor before dividing.

Flashcards

Exam questions

Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.

mcq1 mark

What does 11 DIV 2 evaluate to?

  • 5.5
  • 6
  • 5
  • 1

Mark scheme: 1 mark for 5, the integer quotient. 5.5 would be real division, 6 is the rounded-up value and 1 is the remainder.

calc2 marks

A program divides 11 by 2 using integer division and then calculates the remainder. State the value of the integer division and the value of the remainder.

Answer: Integer division 11 DIV 2 = 5; remainder 11 MOD 2 = 1.

six6 marks

Explain in English the difference between real division and integer division, and why a program might need both.

Mark scheme: Level 1 (1-2 marks): A short answer saying real division keeps the fraction and integer division does not. Level 2 (3-4 marks): A structured answer with the 11 divided by 2 example and the two stages. Level 3 (5-6 marks): A detailed answer explaining that real division gives 5.5 while integer division gives 5 and the remainder 1, explaining that the two values together reconstruct the division because 5 x 2 + 1 = 11, explaining that the choice depends on the data type and on the purpose — totals, averages and remainders for cycling through days or months — and explaining that integer division by zero is an error so the divisor must be validated.

Other sections in this topic

Practise these questions

Answer them in the interactive view and they get marked against the same mark scheme, one mark at a time, with the reason for each mark.

Open the interactive topic →