9618 · 11.2
Constructs flashcards
Revision flashcards for Cambridge 9618 Constructs (syllabus 11.2). Flip, recall, then mark a real past-paper question.
Card
What is Sequence in programming?
The execution of statements one after another in the order they are written in the source code. It is the default control structure.
Card
What is Selection in programming?
A control structure that allows a program to make a choice and execute a specific block of code based on whether a condition is true or false.
Card
What is Iteration in programming?
A control structure that allows a block of code to be executed repeatedly. Also known as repetition or looping.
Card
What is the structure of a count-controlled loop in Cambridge pseudocode?
`FOR <identifier> <- <value1> TO <value2> ... NEXT <identifier>`. It repeats a set number of times.
Card
What is a pre-condition loop?
A loop where the condition is tested *before* each iteration. If the condition is initially false, the loop body will not execute at all. Example: `WHILE...DO...ENDWHILE`.
Card
What is a post-condition loop?
A loop where the condition is tested *after* each iteration. The loop body is guaranteed to execute at least once. Example: `REPEAT...UNTIL`.
Card
When is a `CASE` statement preferable to an `IF...THEN...ELSEIF` structure?
When checking a single variable or expression against multiple constant values. It can be more readable and efficient than a long chain of `IF` statements.
Card
What is the purpose of the `OTHERWISE` clause in a `CASE` statement?
It acts as a default case, executing a block of code if the variable being tested does not match any of the preceding `OF` values. It is good practice for handling unexpected values.
Card
What is a key difference between `WHILE...DO` and `REPEAT...UNTIL` loops?
`WHILE` checks the condition at the start (may not run), while `REPEAT` checks at the end (always runs at least once).
Card
What is meant by 'nesting' constructs?
Placing one control structure inside another. For example, an `IF` statement inside a `FOR` loop, or a `WHILE` loop inside another `WHILE` loop.
Card
What is a common trap with `REPEAT...UNTIL` loops?
The loop terminates when the condition is TRUE. This is the opposite of a `WHILE` loop, which continues as long as its condition is TRUE.