Cambridge IGCSE · Topic 8.1
IGCSE Computer Science 0478 / Topic 8 / IGCSE

Calculate, compare, combine.

Operators are the working parts of every expression. Arithmetic operators calculate, relational operators compare two values, and logical operators join conditions together. Learn exactly which ones the 0478 syllabus uses and how to evaluate them.

The key idea

Arithmetic operators: + - * / ^ (raised to the power of), plus MOD and DIV. Relational operators: = < <= > >= and <> (not equal to); they compare two values and always give a BOOLEAN result. Logical operators: AND (TRUE only if both sides are TRUE), OR (TRUE if either side is TRUE) and NOT (reverses TRUE and FALSE). Powers are worked out first, then * and /, then + and -; brackets make the order explicit.

ArithmeticRelationalLogical calculatecomparecombine conditions + - * /^ (power)MOD (remainder)DIV (wholequotient) =<<=>>=<> ANDORNOT equal toless thanless or equalgreater thangreater or equalnot equal to botheitherreverses relational and logical operators always give a BOOLEAN: TRUE or FALSE
Fig. 1: the three groups of operators in 0478 pseudocode
Section 01

Arithmetic operators.

Work out each expression using the normal mathematical order: brackets, then powers, then multiplication and division, then addition and subtraction.

DECLARE Result : REAL
Result ← 7 + 3 * 2
OUTPUT Result
Result ← (7 + 3) * 2
OUTPUT Result
Result ← 2 ^ 3 + 1
OUTPUT Result
Result ← 7 / 2
OUTPUT Result
ExpressionWorkingResult
7 + 3 * 23 * 2 = 6 first, then 7 + 613
(7 + 3) * 2brackets first: 10 * 220
2 ^ 3 + 12 ^ 3 = 8, then 8 + 19
7 / 2ordinary division3.5
DIV(7, 2) and MOD(7, 2)whole quotient and remainder3 and 1

The same idea in Python (for comparison only: the exam uses pseudocode)

print(7 + 3 * 2)    # 13
print(2 ** 3 + 1)   # 9: Python writes powers as **
print(7 / 2)        # 3.5
print(7 // 2, 7 % 2)  # 3 1: Python's DIV and MOD
Worked example Area of a circle
Evaluate Area ← 3.142 * 5 ^ 2.
  1. The power is worked out first: 5 ^ 2 = 25.
  2. Then the multiplication: 3.142 * 25.
Answer: 78.55
Examiner trap

/ gives the full answer, including any fractional part: 7 / 2 is 3.5. Use DIV only when you want the whole-number quotient, 3.

Section 02

Relational operators.

A relational operator compares two values. The answer is always TRUE or FALSE, which is why these expressions are used as conditions in IF statements and loops.

OperatorMeaningExampleResult
=equal to5 = 5TRUE
<less than8 < 3FALSE
<=less than or equal to4 <= 4TRUE
>greater than4 > 4FALSE
>=greater than or equal to9 >= 2TRUE
<>not equal to6 <> 7TRUE
Worked example Evaluate the conditions
Score is 50. Evaluate Score > 50, Score >= 50 and Score <> 49.
  1. 50 > 50: 50 is not greater than itself, so FALSE.
  2. 50 >= 50: equal counts, so TRUE.
  3. 50 <> 49: they are different, so TRUE.
Answer: FALSE, TRUE, TRUE
Your turn
Lives is 0. What is Lives <= 0?
Examiner trap

In a condition, = compares; it does not store anything. Assignment always uses the arrow ←. (Python uses == to compare and != for not equal.)

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is the value of 2 + 3 * 4?

Quick check+10 XP

What data type is the result of a relational operation such as X > 5?

Quick check+10 XP

The lab's range check accepts ages from 11 to 18. Which input is rejected?

Quick check+10 XP

What is NOT (5 > 3)?

Section 03

Logical: AND, OR, NOT.

The lab's Range check program accepts an age from 11 to 18. Run it with the different kinds of test data and look at how OR rejects values and AND accepts them.

IF Age >= 11 AND Age <= 18
  THEN
    OUTPUT "Valid age"
  ELSE
    OUTPUT "Out of range"
ENDIF
ABA AND BA OR BNOT A
FALSEFALSEFALSEFALSETRUE
FALSETRUEFALSETRUETRUE
TRUEFALSEFALSETRUEFALSE
TRUETRUETRUETRUEFALSE
Worked example A discount rule
A cinema gives a discount when (Age < 12 OR Age > 65) AND Member = TRUE. Is there a discount for Age = 10 and Member = TRUE?
  1. Brackets first: 10 < 12 is TRUE, so the OR is TRUE.
  2. Member = TRUE is TRUE.
  3. TRUE AND TRUE is TRUE.
Answer: Yes, the condition is TRUE
Your turn
Same rule: Age = 40 and Member = TRUE?
Examiner trap

Each side of AND or OR must be a complete comparison. Age > 11 AND < 18 is wrong; write Age > 11 AND Age < 18.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

What is the value of 10 - 2 ^ 3?

Exam style+20 XP

Which condition is TRUE only when Temp is outside the range 15 to 25?

Exam style+20 XP

Which relational operator means not equal to?

Exam style+20 XP

A is 6 and B is 4. What is (A > 5 AND B > 5) OR A = 6?

Skill unlocked

Operators, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Evaluating arithmetic expressions, comparisons and logical conditions, and writing conditions with AND, OR and NOT.