Professional Documents
Culture Documents
Program Flow
Introduction
Programming languages have a set of statements to determine how to reach a goal. The FLOW of these
statements is CONTROLLED by 3 different structures:
Sequencing
(Performing one instruction after another)
Selection
(The program making decisions)
Iteration
(The program repeating, looping infinitely or for a set number of
times)
Sequencing
A sequence is a control structure where the computer executes every instruction in the order in which they
are written. Here is an example of sequencing in an algorithm:
Computer Science UK Membership Site Licence: Do not share outside your centre. 1
A-Level Computer Science
Often we want programs to act differently when certain conditions occur. Selection is a control structure
which contains instructions that DO NOT have to be executed in sequence (non-sequential).
There are two main types of selection.
Selection of 2 possible pathways (IF-THEN-ELSE statements)
Multiple Selections (CASE statements (uses the keyword ELIF in Python))
Computer Science UK Membership Site Licence: Do not share outside your centre. 2
A-Level Computer Science
This states that WHILE a certain condition is true, the code will continue repeating. The check occurs at the
start of each loop. The instructions in the loop will be ignored if the WHILE condition is false.
Questions
1. Name the 3 constructs of a programming language? [3]
2. Describe how each of the three constructs above control the flow of instructions in a program? [3]
3. Copy the code shown at the bottom of the page and identify (by labelling) the various parts of the
code where the three programming constructs have been used. [3]
4. Explain the difference between how FOR loops and WHILE loops control the flow of instructions
during the running of a program. [4]
5. Explain how iteration controls the flow of instructions in a program and explain the difference
between how a ‘while loop’ and a ‘do until’ structure controls the flow of instructions. [4]
6. Although IF statements allow for only 2 possible pathways, IF statements can be nested within
themselves to allow for multiple pathways. Describe another method that can be used to enable the
programming of multiple possible pathways.
Computer Science UK Membership Site Licence: Do not share outside your centre. 3
A-Level Computer Science
7. Write a short program which makes use of all three programming constructs.[5]
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
Computer Science UK Membership Site Licence: Do not share outside your centre.
4
_____________________________________________________
A-Level Computer Science
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
Computer Science UK Membership Site Licence: Do not share outside your centre.
5
A-Level Computer Science
State/Identify/Give/Name: Simply label a diagram, fill out a table or write a few words
Describe: Describing is ‘saying what you see’ (E.G.: A computer will have a CPU, Primary and Secondary storage etc)
Explain: Explaining is ‘saying WHY/HOW something is like that’. (E.G.: A computer will have a CPU so that it can process all of the data the
computer needs to perform a range of tasks. Primary and Secondary storage is needed because…)
Discuss: Discussing is ‘looking at two sides of an issue, weighing up the two views and giving a conclusion’. Often these require a mini essay
answer. (E.G.: New technology could be seen as being bad for the environment because…, but on the other hand, new technology has led to…
In conclusion I believe that…)
Describe/Explain/Discuss using examples: Finally, if you are asked to give examples in any of these types of questions – YOU MUST GIVE
EXAMPLES!
Computer Science UK Membership Site Licence: Do not share outside your centre. 6
A-Level Computer Science
Further thoughts:
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
Computer Science UK Membership Site Licence: Do not share outside your centre. 7