Skip to main content
EnglandComputer ScienceSyllabus dot point

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.

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. Comparison operators
  4. Boolean operators
  5. Operator precedence
  6. Comparison operators in conditions
  7. Combining Boolean operators with comparisons
  8. Try this

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 \ne, less than <<, greater than >>, less than or equal to \le, and greater than or equal to \ge. 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 \leftarrow 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 23 MOD 423 \text{ MOD } 4. [1 mark]

  • Cue. 3, because 23÷4=523 \div 4 = 5 remainder 3.

Q2. State the result of True AND False and of True OR False. [2 marks]

  • Cue. True AND False is False; True OR False is 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 →

23 DIV 4=523 \text{ DIV } 4 = 5, because 44 goes into 2323 five whole times. 23 MOD 4=323 \text{ MOD } 4 = 3, because 5×4=205 \times 4 = 20 and 2320=323 - 20 = 3 is the remainder.

For 2+6×32 + 6 \times 3, precedence does multiplication before addition: 6×3=186 \times 3 = 18 first, then 2+18=202 + 18 = 20.

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: 2024 MOD 4=02024 \text{ MOD } 4 = 0 (since 2024=506×42024 = 506 \times 4), 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

Sources & how we know this