Selection and iteration: IF, CASE and loops
Watch the whole lecture free
Make a free account to watch every lecture to the end: 9 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: 9 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: 9 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
- Decisions and repeats
- IF statements
- Nested IF
Read the transcript of the teaching part
Last time
Before we start: last time, in Arrays, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.
Decisions and repeats
Programs do two clever things. They decide: if the battery is low, show a warning. And they repeat: check the battery every minute. Deciding is called selection, and repeating is called iteration. Together with sequence, they build every program ever written.
IF statements
Selection means a condition is tested, and a different path is followed. IF THEN ENDIF gives one option: do something only when the condition is true. Adding ELSE gives two options. Put THEN and ELSE on their own lines, and indent, so it is easy to read.
Nested IF
The first one hundred units cost ten each. The next two hundred cost fifteen. The rest cost twenty. If units are a hundred or fewer, bill is units times ten. Otherwise, if units are at most three hundred, it is one thousand plus fifteen for each unit over a hundred. Otherwise, four thousand plus twenty for each unit over three hundred.
Chapter 8.1: Selection and iteration
- Selection and iteration: IF, CASE and loops 6 min
Also for IGCSE Computer Science 0478
Which topics come up most in IGCSE Computer Science 0478 past papers, counted from every paper since 2004: Paper 1 topic frequency, Paper 2 topic frequency.