Skip to main content
EnglandComputer ScienceSyllabus dot point

How do programs perform arithmetic, comparison and logical operations on data?

Use arithmetic operations including integer division, modulus and exponentiation, relational operators, and the Boolean operators AND, OR and NOT, and understand operator precedence.

A focused answer to AQA A-Level Computer Science 4.1.3, covering arithmetic operators including integer division and modulus, relational operators, the Boolean operators AND, OR and NOT, and operator precedence.

Generated by Claude Opus 4.88 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Arithmetic operators
  3. Relational and Boolean operators
  4. Operator precedence

What this dot point is asking

AQA wants you to use arithmetic operators (including integer division and modulus), relational operators that produce a Boolean result, and the logical operators AND, OR and NOT, and to apply operator precedence correctly.

Arithmetic operators

  • Addition, subtraction, multiplication: the usual operators on integers and reals.
  • Real division (/): gives a real result, so 7/2=3.57 / 2 = 3.5.
  • Exponentiation: raises to a power, so 210=10242^{10} = 1024.
  • DIV and MOD: integer division and remainder, used for digit extraction, wrapping values round (as in a circular queue) and divisibility tests.

DIV and MOD together are powerful for breaking numbers apart. Repeatedly applying nMOD10n \,\text{MOD}\, 10 extracts the last digit and nDIV10n \,\text{DIV}\, 10 removes it, which is exactly how a number is converted to its individual digits or to another base. This pairing appears constantly in exam algorithms, so it is worth being fluent with both.

Relational and Boolean operators

Relational operators compare two values and return a Boolean: == (equal), \neq (not equal), <<, >>, \leq and \geq. The result is True or False, which is why a condition in an IF or WHILE is really a Boolean expression.

A useful related idea is short-circuit evaluation, used by many languages: in A AND B, if A is False the whole expression must be False, so B is not even evaluated; in A OR B, if A is True then B is skipped. This both saves time and lets a programmer guard a risky test, for example checking a list is non-empty before accessing its first element in the same condition.

Operator precedence

When several operators appear in one expression, precedence decides the order: brackets first, then exponentiation, then *, /, DIV and MOD, then + and -, and finally the relational and Boolean operators. So 2+3×4=142 + 3 \times 4 = 14, not 2020, because multiplication is done before addition. Operators of equal precedence are evaluated left to right. Use brackets to make the intended order explicit and the expression readable, even where they are not strictly required.

Exam-style practice questions

Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AQA 20194 marksA program needs to split a total number of seconds into whole minutes and remaining seconds. Using the DIV and MOD operators, write expressions for the number of whole minutes and the leftover seconds when totalSeconds = 200, and evaluate both.
Show worked answer →

Whole minutes use integer division: minutes=totalSecondsDIV60\text{minutes} = \text{totalSeconds} \,\text{DIV}\, 60. Leftover seconds use modulus: seconds=totalSecondsMOD60\text{seconds} = \text{totalSeconds} \,\text{MOD}\, 60.

Evaluating with totalSeconds = 200: 200DIV60=3200 \,\text{DIV}\, 60 = 3 (because 3×60=1803 \times 60 = 180 fits, 4×60=2404 \times 60 = 240 does not), and 200MOD60=20200 \,\text{MOD}\, 60 = 20 (the remainder 200180200 - 180).

So 200 seconds is 3 minutes and 20 seconds.

Markers reward choosing DIV for the whole minutes and MOD for the remainder, and the correct values 3 and 20.

AQA 20213 marksEvaluate the expression 4 + 6 / 2 * 3 - 1 according to standard operator precedence, showing the order in which the operations are performed.
Show worked answer →

Precedence: division and multiplication are done before addition and subtraction, and are evaluated left to right.

First 6/2=36 / 2 = 3. Then 3×3=93 \times 3 = 9 (using the result of the division). The expression is now 4+914 + 9 - 1. Then 4+9=134 + 9 = 13, and 131=1213 - 1 = 12.

The result is 12.

Markers reward applying multiplication and division before addition and subtraction, working left to right, and reaching 12. A candidate who evaluates strictly left to right and gets 14 loses the precedence marks.

Related dot points

Sources & how we know this