What are the arithmetic, comparison and Boolean operators, and what do MOD and DIV do?
The common operators: arithmetic (add, subtract, multiply, divide, exponent, MOD and DIV), comparison operators, and Boolean operators (AND, OR, NOT), and how they are used in expressions.
An OCR J277 2.2.2 answer on the common operators: arithmetic (including exponent, MOD and DIV), comparison operators, and the Boolean operators AND, OR and NOT, with worked examples of integer division and modulus.
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
OCR wants you to use the common operators in expressions: arithmetic (add, subtract, multiply, divide, exponent, MOD and DIV), comparison operators (equal to, not equal to, less than and so on), and the Boolean operators (AND, OR, NOT). The pair that is examined most is MOD and DIV, so you must be confident with integer division and remainder. This is examined throughout Paper 2.
Arithmetic operators
MOD and DIV are powerful. number MOD 2 == 0 tests whether a number is even (remainder 0). MOD and DIV convert seconds to minutes and seconds: mins = total DIV 60 and secs = total MOD 60.
Comparison operators
Boolean operators
Try this
Q1. State the result of and . [2 marks]
- Cue. and (since , remainder 3).
Q2. Write a Boolean expression that is true when a number n is even. [1 mark]
- Cue.
n MOD 2 == 0.
Q3. State what the Boolean operator OR does. [1 mark]
- Cue. It gives true when at least one of the conditions it joins is true.
Exam-style practice questions
Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
OCR 20213 marksState the result of each of the following expressions: (a) 17 DIV 5, (b) 17 MOD 5, (c) 2 ^ 4.Show worked answer →
(a) . DIV is integer (whole-number) division: it gives how many whole times 5 goes into 17, which is 3, discarding the remainder.
(b) . MOD gives the remainder after that division: .
(c) . The exponent operator raises 2 to the power 4, that is .
Markers reward the three correct values. The most common error is swapping DIV and MOD: DIV gives the whole-number quotient, MOD gives the remainder.
OCR 20224 marksA program checks whether a user can enter a club: they must be aged 18 or over AND be a member. Write the condition for an if statement, and explain what the Boolean operators AND, OR and NOT do.Show worked answer →
Condition (1 mark): if age >= 18 AND member == true then. Both parts must be true for entry, so AND is correct.
The operators (up to 3, one each): AND is true only when both conditions are true. OR is true when at least one condition is true. NOT reverses a condition, so NOT true is false and NOT false is true.
Markers reward a correct condition using AND, and a precise meaning for each operator. Saying AND means "and also" without the "both must be true" idea is not enough for the mark.
Related dot points
- The use of variables and constants, the common data types (integer, real, Boolean, character and string), choosing an appropriate data type, and casting (converting) between data types.
An OCR J277 2.2.1 answer on variables and constants, the common data types (integer, real, Boolean, character, string), choosing an appropriate data type for data, and casting between data types.
- The three basic programming constructs: sequence, selection (if and switch/case) and iteration (count-controlled for loops and condition-controlled while and do until loops), and when to use each.
An OCR J277 2.2.2 answer on the three programming constructs: sequence, selection (if and switch/case) and iteration (count-controlled for loops and condition-controlled while and do until loops), with the OCR Exam Reference Language for each.
- Boolean logic: the operators AND, OR and NOT, applying them to expressions, and constructing truth tables for simple logic statements including combinations of operators.
An OCR J277 2.4.1 answer on Boolean logic: the operators AND, OR and NOT, applying them to expressions, and constructing truth tables for simple logic statements and combinations of operators.
- The use of subprograms (procedures and functions), passing parameters into a subprogram, returning values from a function, local versus global variable scope, and generating random numbers.
An OCR J277 2.2.3 answer on subprograms: procedures and functions, passing parameters, returning values, the difference between local and global variables, the benefits of subprograms, and generating random numbers.
- Converting between denary and binary (up to and including 8 bits), binary addition and the detection of overflow, and binary shifts and their effect.
An OCR J277 1.2.4 answer on converting between denary and binary up to 8 bits, adding binary numbers and detecting overflow, and binary shifts and their effect on a value.
Sources & how we know this
- OCR GCSE (9-1) Computer Science (J277) specification — OCR (2020)