Skip to content

Once a decision point has been found, the next step is to state exactly what is tested there.

Definition
A logical condition is an expression that evaluates to either true or false. It is built from comparison operators and can be combined with the Boolean operators AND, OR and NOT.

Comparison and Boolean Operators

Key Point
OperatorMeaningExample that is true when age = 16
==Equal toage == 16
!=Not equal toage != 18
< and <=Less than; less than or equal toage <= 16
> and >=Greater than; greater than or equal toage > 12
ANDTrue only when both conditions are trueage >= 13 AND age <= 19
ORTrue when at least one condition is trueage < 5 OR age > 12
NOTReverses the resultNOT (age == 18)

Working Out the Condition for Each Decision

Worked Example
Worked Example: Cinema Tickets

A cinema sells a child ticket to anyone under 13 and a senior ticket to anyone aged 65 or over. Everyone else pays the standard price.
pseudocode
if age < 13 then
    ticket = "child"
elseif age >= 65 then
    ticket = "senior"
else
    ticket = "standard"
end if
ageage < 13age >= 65ticket
12TrueNot testedchild
13FalseFalsestandard
64FalseFalsestandard
65FalseTruesenior
Testing the values on each side of a boundary shows whether a condition needs < or <=.
Exam Tip
State a condition exactly: "age is less than 13", not "the customer is young". Test the values on each side of every boundary, and check the order of the conditions, because once one condition is true the ones after it are not tested.