OCR · GCSE · Computer Science
Course version: J277 · Version from Sept 2022
The use of the three basic programming constructs used to control the flow…
Full specification wording
Programming fundamentals: The use of the three basic programming constructs used to control the flow of a program Sequence Selection Iteration (count- and condition-controlled loops)
Program flow is controlled by three constructs.
Checked against the OCR J277 specification on .
- Point 2 of 4
- 4 key terms
Study notes
From the checked teaching notes for this specification point.
The idea
Program flow is controlled by three constructs. Sequence executes statements one after another in written order, for example reading a sensor then storing its value then displaying it. Selection chooses between paths using a condition, such as IF score >= 50 THEN grade = "pass" ELSE grade = "fail". Iteration repeats code: count-controlled loops repeat a known number of times, for example FOR i = 1 TO 10, while condition-controlled loops repeat while or until a condition changes, for example WHILE answer != "yes" or REPEAT ... UNTIL valid. Combining constructs lets a programmer express any algorithm: a menu uses selection inside a condition-controlled loop, and processing a list uses a count-controlled loop containing selection. Choosing the right construct makes code readable, correct and efficient, and exam questions ask you to trace, write or correct code using them.
What earns the marks
- Sequence: statements execute in the order written, so swapping two lines can change the result; tracing follows that order line by line.
- Selection: a condition is evaluated and exactly one branch runs, for example IF ... THEN ... ELSE ... or a CASE statement; the condition must be Boolean.
- Count-controlled iteration: the number of repetitions is known or calculated before the loop starts, for example FOR i = 1 TO 5 or a loop over a fixed list.
- Condition-controlled iteration: repetition continues while or until a condition is tested, for example WHILE lives > 0 or REPEAT ... UNTIL password = "secret".
- Nesting: constructs can be placed inside one another, so a selection can sit inside a loop and a loop can sit inside a selection.
- Tracing: track variable values after each iteration or branch to predict output and to find logic errors.
Common mistakes and how to put them right
Confusing count-controlled and condition-controlled loops.
Put it right: A FOR loop is used when the number of repeats is known, while a WHILE loop is used when repetition depends on a condition; choose the construct that matches the problem.
Writing a condition-controlled loop whose condition never becomes false, producing an infinite loop.
Put it right: Ensure the loop body changes a variable used in the condition, for example incrementing a counter.
Forgetting that an IF without ELSE simply skips its body when the condition is false, so no alternative action occurs.
Put it right: Add ELSE when a different path is required.
Using = instead of a comparison operator in a condition, or mixing up < and >, which changes which branch runs.
Put it right: Check the operator against the intended meaning.
Exam tips
- Read the question's wording for clues: 'repeat until' or 'while' signals condition-controlled iteration, while 'for each' or a fixed number signals count-controlled iteration.
- When tracing, draw a table of variables and update it after every line or iteration so the final output is easy to justify.
- When writing code, indent nested constructs clearly; this helps you and the examiner see which statements belong to which branch or loop.
- Check loop conditions by asking what value makes the loop stop and whether the body moves the variable towards that value.
Try the lesson
The start of the Programming fundamentals: The use of the three basic programming constructs used to control the flow of a program Sequence Selection Iteration (count- and condition-controlled loops) lesson, made from checked teaching notes for this specification point.
Have a go first
Which programming construct runs statements one after another in the order they are written?
Listen
Program flow is controlled by three constructs. Sequence executes statements one after another in written order, for example reading a sensor then storing its value then displaying it. Selection chooses between paths using a condition, such as IF score >= 50 THEN grade = "pass" ELSE grade = "fail". Iteration repeats code: count-controlled loops repeat a known number of times, for example FOR i = 1 TO 10, while condition-controlled loops repeat while or until a condition changes, for example WHILE answer != "yes" or REPEAT ... UNTIL valid. Combining constructs lets a programmer express any algorithm: a menu uses selection inside a condition-controlled loop, and processing a list uses a count-controlled loop containing selection. Choosing the right construct makes code readable, correct and efficient, and exam questions ask you to trace, write or correct code using them. A strong answer earns marks for these points. Sequence: statements execute in the order written, so swapping two lines can change the result; tracing follows that order line by line. Selection: a condition is evaluated and exactly one branch runs, for example IF ... THEN ... ELSE ... or a CASE statement; the condition must be Boolean. Count-controlled iteration: the number of repetitions is known or calculated before the loop starts, for example FOR i = 1 TO 5 or a loop over a fixed list. Condition-controlled iteration: repetition continues while or until a condition is tested, for example WHILE lives > 0 or REPEAT ... UNTIL password = "secret". Exam tip: Read the question's wording for clues: 'repeat until' or 'while' signals condition-controlled iteration, while 'for each' or a fixed number signals count-controlled iteration.
See it
Key words
Say what each word means before you turn the card.
Sequence
Try answering aloud or in your head before turning the card.
Selection
Try answering aloud or in your head before turning the card.
Count-controlled iteration
Try answering aloud or in your head before turning the card.
Condition-controlled iteration
Try answering aloud or in your head before turning the card.
See every definition
- Sequence
- Statements execute in the order written, so swapping two lines can change the result.
- Selection
- A condition is evaluated and exactly one branch runs, for example IF ... THEN ... ELSE ... or a CASE statement.
- Count-controlled iteration
- The number of repetitions is known or calculated before the loop starts, for example FOR i = 1 TO 5.
- Condition-controlled iteration
- Repetition continues while or until a condition is tested, for example WHILE lives > 0 or REPEAT ... UNTIL password = "secret".
Label the diagram
Some boxes have lost their names. Pick the right name for each number.
1Box 1
2Box 2
3Box 3
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Programming fundamentals: The use of the three basic programming constructs used to control the flow of a program Sequence Selection Iteration (count- and condition-controlled loops)
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge