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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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 . - Exponentiation: raises to a power, so .
DIVandMOD: 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 extracts the last digit and 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), (not equal), , , and . 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 , not , 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: . Leftover seconds use modulus: .
Evaluating with totalSeconds = 200: (because fits, does not), and (the remainder ).
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 . Then (using the result of the division). The expression is now . Then , and .
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
- Understand the built-in data types: integer, real or float, Boolean, character and string, and understand records, arrays and user-defined data types built from them.
A focused answer to AQA A-Level Computer Science 4.1.1, covering the built-in data types (integer, real, Boolean, character, string), how each is stored, and how records, arrays and user-defined types are built from them.
- Understand and use the three basic programming constructs (sequence, selection and iteration), definite and indefinite iteration, nested constructs, and the meaning of constants and variables.
A focused answer to AQA A-Level Computer Science 4.1.2, covering the three basic constructs sequence, selection and iteration, definite and indefinite iteration, nesting, and the difference between constants and variables.
- Understand and use subroutines (procedures and functions), parameters, return values, local and global variables, scope, and the use of an interface and recursion.
A focused answer to AQA A-Level Computer Science 4.1.4 and 4.1.6, covering procedures and functions, parameters and return values, local and global scope, the benefits of subroutines, and recursion.
- Understand the logic gates NOT, AND, OR, XOR, NAND and NOR, their truth tables, combining gates into logic circuits, and simplifying expressions using Boolean algebra.
A focused answer to AQA A-Level Computer Science 4.6.2 and 4.6.3, covering the logic gates NOT, AND, OR, XOR, NAND and NOR, their truth tables, building logic circuits, and simplifying Boolean expressions using the laws of Boolean algebra.
- Understand unsigned and signed binary using two's complement, binary addition and subtraction, fixed point and floating point representation of real numbers, and the effects of overflow and rounding.
A focused answer to AQA A-Level Computer Science 4.5.2 to 4.5.7, covering unsigned and signed binary using two's complement, binary addition and subtraction, fixed and floating point representation of real numbers, and overflow and rounding errors.
Sources & how we know this
- AQA A-level Computer Science (7517) specification — AQA (2015)