How does a program do calculations and make logical decisions?
Use arithmetic operators including integer division and modulus, comparison operators, and the Boolean operators AND, OR and NOT, applying correct operator precedence.
A focused answer to AQA GCSE Computer Science 3.2.3 and 3.2.4, covering arithmetic operators including integer division and modulus, comparison operators, and the Boolean operators AND, OR and NOT with 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 DIV and modulus MOD), comparison operators, and the Boolean operators AND, OR and NOT, applying the correct order of precedence.
Arithmetic operators
DIV and MOD work as a pair: for any division, DIV gives how many whole times the divisor fits and MOD gives what is left over. MOD is especially useful for tests such as "is this number even?" (number MOD 2 = 0), "is it divisible by 5?" (number MOD 5 = 0), or wrapping a value around a range (such as turning a 25-hour count into a clock time with hours MOD 24).
Comparison operators
Comparison operators compare two values and return a Boolean (True or False): equal to , not equal to , less than , greater than , less than or equal to , and greater than or equal to . They form the conditions inside selection (IF) and iteration (WHILE), where the program needs a True or False answer to decide what to do.
Boolean operators
For example age >= 13 AND age <= 19 is True only for teenagers, because both halves must hold. day = 'Sat' OR day = 'Sun' is True at the weekend, because either is enough.
Operator precedence
Comparison operators in conditions
Comparison operators are what turn data into the True or False answer a program needs to make a decision. Inside an IF or a WHILE, a condition such as score >= passMark is evaluated to a Boolean and the program branches or loops accordingly. The six operators are equal to, not equal to, less than, greater than, less than or equal to, and greater than or equal to. A frequent source of bugs is mixing up "equal to" used as a test with "assignment" used to store a value: in AQA pseudocode the assignment arrow stores a value, while tests for equality inside a condition.
Combining Boolean operators with comparisons
Real conditions usually combine comparisons with Boolean operators. For example mark >= 40 AND mark < 70 is True for a pass that is not a distinction, and day = 'Sat' OR day = 'Sun' is True at the weekend. NOT inverts a condition, so NOT loggedIn is True when the user is not logged in. As with arithmetic, precedence and brackets matter: NOT is applied first, then AND, then OR, so brackets are used to make the intended logic clear, such as (a OR b) AND c. Building conditions carefully from comparisons and Boolean operators is the heart of writing correct selection and iteration.
Try this
Q1. Calculate . [1 mark]
- Cue. 3, because remainder 3.
Q2. State the result of True AND False and of True OR False. [2 marks]
- Cue.
True AND Falseis False;True OR Falseis True.
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 20183 marksCalculate the values of 23 DIV 4, 23 MOD 4, and 2 + 6 * 3, showing how operator precedence is applied to the last expression.Show worked answer →
, because goes into five whole times. , because and is the remainder.
For , precedence does multiplication before addition: first, then .
Markers reward the correct DIV (whole quotient) and MOD (remainder) values and applying precedence (multiply before add) to reach 20, not 24.
AQA 20214 marksA program decides if a year is a leap year. A year is a leap year if it is divisible by 4. Write a condition using a suitable operator, and explain why MOD is the correct operator to use. Give the result of your condition for the year 2024.Show worked answer →
The condition is year MOD 4 = 0. MOD gives the remainder of dividing the year by 4, so a remainder of 0 means the year divides exactly by 4, which is the test for a leap year.
For 2024: (since ), so the condition is True and 2024 is a leap year.
Markers reward the correct use of MOD for a divisibility test, the comparison to 0, and the correct True result for 2024.
Related dot points
- Use the common data types, declare and assign variables and constants, and understand the difference between a variable and a constant.
A focused answer to AQA GCSE Computer Science 3.2.1, covering the common data types, declaring and assigning variables and constants, and the difference between a variable and a constant.
- Use the three programming constructs of sequence, selection and iteration, including definite and indefinite iteration, and nest them.
A focused answer to AQA GCSE Computer Science 3.2.2, covering the three programming constructs of sequence, selection and iteration, the difference between definite and indefinite iteration, and nesting.
- Understand the AND, OR and NOT logic gates, construct and interpret truth tables, and build and read simple logic circuits.
A focused answer to AQA GCSE Computer Science 3.4.2, covering the AND, OR and NOT logic gates, constructing and interpreting truth tables, and building and reading simple logic circuits.
- Use common string-handling operations including length, position, substring, concatenation, and converting between case and between strings and numbers.
A focused answer to AQA GCSE Computer Science 3.2.9, covering common string-handling operations such as length, position, substring, concatenation, case conversion and converting between strings and numbers.
Sources & how we know this
- AQA GCSE Computer Science (8525) specification — AQA (2020)