Computer ScienceExam code: 0984

Programming Concepts

Programming

Comparison operators compare two values and return a (TRUE or FALSE). They are the building blocks of IF statements and loop conditions.

OperatorMeaningExampleResult
=Equal toAge = 18TRUE if age is 18
<>Not equal toScore <> 0TRUE if score is not zero
<Less thanSpeed < 30TRUE if speed under 30
>Greater thanTemperature > 25TRUE if temperature over 25
<=Less than or equal toMark <= 40TRUE if mark is 40 or below
>=Greater than or equal toAge >= 18TRUE if age is at least 18

Common slip: in some real programming languages (Python, Java), the test for equality is ==, not =. In CIE pseudocode the single = is correct, so use it in pseudocode answers.

Common exam question

Identifying operators and their types

Question: Tick the operator that means less than or equal to, or draw lines from operators such as >=, AND, DIV and + to the operator types arithmetic, logical and Boolean (1–4 marks).

Asked in 2 of the 17 papers, one mark per correct tick or line. Know the symbols: <= is less than or equal to, >= greater than or equal to and <> not equal to; the wrong options offered were OR, < and >=.

Sort operators by what they do, because the group names have changed. +, -, *, /, ^, DIV and MOD calculate a number: arithmetic. =, <, <=, >, >= and <> compare two values: relational in the current syllabus, labelled "logical" on earlier papers. AND, OR and NOT combine TRUE and FALSE values: logical now, labelled "Boolean" on earlier papers. So with the labels Boolean, arithmetic and logical on offer, >= goes to logical, AND to Boolean, and DIV and + to arithmetic.

Build on this topic