Cambridge O Level Computer Science · Syllabus 2210 · Programming
Selection
What is Selection?
A control structure that chooses which statements to execute according to whether a condition evaluates to TRUE or FALSE; written in Cambridge pseudocode as an IF statement or a CASE OF statement.
This definition is part of the Programming chapter in Cambridge O Level Computer Science.
Selection in context
A program is a stored sequence of instructions that manipulates data held in named storage. Topic 8 asks you to do four things with that idea. First, name and type your data correctly: a variable whose value may change, a constant whose value may not, each with one of the five data types INTEGER, REAL, CHAR, STRING, BOOLEAN. Second, control the order in which instructions run using only three structures — sequence, selection (IF, CASE) and iteration (FOR, WHILE, REPEAT). Third, break a long solution into procedures and functions so it stays readable and testable. Fourth, hold many related values in an array and hold them beyond the end of the run in a file. Everything else in this chapter is detail hanging off those four moves.
Selection means the program chooses which statements to execute according to whether a condition is TRUE or FALSE. Cambridge pseudocode has two selection structures. An IF statement tests a Boolean condition and may or may not have an ELSE clause; it is the right choice for ranges, comparisons and compound conditions. A CASE OF statement compares one identifier against a list of single discrete values, executes the statement of the first case that applies and then finishes; an OTHERWISE clause, if present, must be the last case.
A statement is nested when it sits entirely inside the block of another statement. The four combinations you must handle are selection inside selection, selection inside iteration, iteration inside selection and iteration inside iteration. The syllabus states that candidates will not be required to write more than three levels of nested statements — so three is the ceiling for anything you produce, and if your answer is heading for four, the right move is to pull the inner part out into a procedure or function.
Common mistakes with Selection
- M6. “CASE is the tidier choice, so use it for every selection.” TruthA case clause matches one single value of one identifier. It cannot express a range or a compound condition. RuleDiscrete values of one variable → CASE. Ranges, comparisons or AND/OR → IF. The specification itself says that if the cases are more complex, an IF should be considered.

