Pseudocode constructs: IF, CASE, records and arrays
Watch the whole lecture free
Make a free account to watch every lecture to the end: 6 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
That was the teaching part. The rest of this lecture is free with an account: 6 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
No password needed now: we email you a link to set one. Already have an account? Sign in, then come back to this page.
The teaching part (1 min) is free to watch. A free account opens the whole lecture: 6 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
What this lecture covers
- Reading code like a sentence
- Three constructs
- IF statements
- CASE statements
Read the transcript of the teaching part
Last time
Before we start: last time, in Finding errors in statements and following an algorithm, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.
Reading code like a sentence
Every algorithm in Paper 2 is built from three ideas. Do things in order. Choose between actions. Repeat actions. Once you can spot which is which, a page of pseudocode stops looking like a wall of words and becomes a few small, familiar pieces.
Three constructs
Sequence: statements run one after another, in the order written. Selection: IF or CASE chooses which statements run, depending on a condition. Iteration: a loop repeats statements. FOR repeats a fixed number of times. WHILE and REPEAT depend on a condition.
IF statements
IF condition THEN statements ELSE statements ENDIF chooses one of two routes. ELSE is optional. Conditions join with AND, OR and NOT. For a weight within 48 and 52 inclusive, both tests must be true. Nested IF statements test further conditions, only when the earlier one is false or true.
CASE statements
CASE OF tests one variable against several values or ranges. It is neater than a long chain of IF statements. Each branch gives a value or a range, then a colon, then statements. A range is written 70 TO 100. OTHERWISE catches everything else. End with ENDCASE. The branches must not overlap.
How often it comes up
How often Cambridge has asked each part, counted by ExamYard from every past paper in its question bank: Records · Searching and processing an array · Selection: IF and CASE.
The whole chapter: Programming Fundamentals.
Chapter 11: Programming
- Pseudocode constructs: IF, CASE, records and arrays 6 min
- Choosing data types and loops, evaluating expressions, and decomposition 5 min
- Finding errors in statements, following algorithms, good practice and identifier tables 6 min
Also for A Level Computer Science 9618
Which topics come up most in A Level Computer Science 9618 past papers, counted from every paper since 2004: Paper 1 topic frequency, Paper 2 topic frequency.