How do we write algorithms using sequence, selection and repetition, with variables, constants and data structures?
Follow and write algorithms (flowcharts, pseudocode, program code) that use sequence, selection, repetition (count-controlled, condition-controlled) and iteration with input, processing and output, and that use variables, constants and one- and two-dimensional data structures (strings, records, arrays).
A focused answer to Edexcel GCSE Computer Science 1.2.1 and 1.2.2, covering writing and following algorithms with sequence, selection and repetition, input-process-output, and variables, constants, strings, records and arrays.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
Edexcel wants you to read and write algorithms in flowcharts, pseudocode and program code that use the three building blocks (sequence, selection and repetition), follow the input then process then output pattern, and use variables, constants and data structures (strings, records and arrays, in one and two dimensions).
Sequence, selection and repetition
These three constructs, plus input and output, are enough to express any algorithm at GCSE. Selection runs a block only when a condition is true; for example, output "pass" if a mark is 40 or more, else output "fail". Repetition avoids writing the same steps many times: a FOR loop counts through a fixed range, while a WHILE loop keeps going while its condition holds, so it is the right choice when you do not know in advance how many repeats are needed (such as "keep asking until the user types a valid value").
Iteration in the Edexcel sense means stepping over every item in a data structure, such as visiting each element of an array in turn. This is usually written as a count-controlled loop over the index positions, or a for-each style loop over the items.
Input, processing and output
For a program that converts a temperature from Celsius to Fahrenheit, the input is the Celsius value, the processing is the calculation , and the output is the Fahrenheit value. Keeping this structure clear makes algorithms easier to design and to trace.
Variables, constants and data structures
Choosing the right structure matters. Use a variable for anything that changes, such as a running total or a loop counter. Use a constant for a value that should never change and is given a name for clarity, such as VAT = 0.20 or MAX_PLAYERS = 4; naming it once means a change only needs making in one place. Use an array when you have a list of similar items (ten exam marks, the days of the week) so you can process them with a loop. Use a two-dimensional array for grid data such as a noughts-and-crosses board or a class-by-week timetable. Use a record when several different facts belong together, such as a contact's name, phone number and email.
Reading flowcharts and pseudocode
Edexcel can present an algorithm as a flowchart, as pseudocode or as program code, and you must be able to follow any of them. In a flowchart, a parallelogram is input or output, a rectangle is a process, and a diamond is a decision (selection) with a true and a false exit; a loop is shown by an arrow that flows back to an earlier point. Pseudocode is informal: it uses plain statements such as set total to 0, if mark >= 40 then, and repeat ... until without strict syntax. Because the board uses all three notations, practise translating between them.
Try this
Q1. State the difference between a count-controlled loop and a condition-controlled loop. [2 marks]
- Cue. A count-controlled (FOR) loop repeats a known, fixed number of times; a condition-controlled (WHILE) loop repeats until a condition becomes false, so the number of repeats need not be known in advance.
Q2. Give one reason for using a two-dimensional array rather than several separate variables. [1 mark]
- Cue. It stores grid or table data under one name so it can be processed with loops, rather than needing many separately named variables.
Exam-style practice questions
Practice questions written in the style of Pearson Edexcel exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Edexcel 20226 marksA program reads 10 exam marks into an array called marks. Write an algorithm, in pseudocode or program code, that outputs the highest mark in the array and how many marks are 40 or above.Show worked answer →
A correct algorithm initialises a highest value and a counter, then iterates over every element of the array, updating both.
highest = marks[0]
passes = 0
for i = 0 to 9
if marks[i] > highest then
highest = marks[i]
end if
if marks[i] >= 40 then
passes = passes + 1
end if
next i
print(highest)
print(passes)
Markers reward: sensible initialisation (highest set to the first element or a low value, counter to 0), a loop that visits all 10 elements, a correct comparison to find the maximum, a correct count of values 40 or above, and output of both results. The two selections sit inside one iteration, which is efficient.
Edexcel 20213 marksState what is meant by a variable, a constant and a record in a program.Show worked answer →
A variable is a named store whose value can change while the program runs (for example a running total). A constant is a named store whose value is fixed and cannot change while the program runs (for example VAT = 0.20). A record is a structured data type that groups together several related values, which may be of different data types, under one name (for example a student record holding a name, a date of birth and a mark).
Markers award one mark each for the three correct definitions; the key discriminators are "can change" versus "fixed", and that a record groups related, possibly mixed-type values.
Related dot points
- Understand the benefit of using decomposition and abstraction to model aspects of the real world and to analyse, understand and solve problems, and understand the benefits of using subprograms.
A focused answer to Edexcel GCSE Computer Science 1.1.1 and 1.1.2, covering how decomposition and abstraction model the real world and help solve problems, and the benefits of using subprograms.
- Follow and write algorithms that use arithmetic operators (addition, subtraction, division, multiplication, modulus, integer division, exponentiation), relational operators (equal to, less than, greater than, not equal to, less than or equal to, greater than or equal to) and logical operators (AND, OR, NOT).
A focused answer to Edexcel GCSE Computer Science 1.2.3, covering the arithmetic operators including modulus and integer division, the relational operators, and the logical operators AND, OR and NOT in algorithms.
- Determine the correct output of an algorithm for a given set of data, and use a trace table to determine what value a variable will hold at a given point in an algorithm.
A focused answer to Edexcel GCSE Computer Science 1.2.4, covering how to dry-run an algorithm, build a trace table row by row, and determine the value a variable holds and the output for given input data.
- Understand syntax, logic and runtime errors and correct logic errors in algorithms; understand how the standard algorithms (bubble sort, merge sort, linear search, binary search) work; and use logical reasoning and test data to evaluate an algorithm's fitness for purpose and efficiency.
A focused answer to Edexcel GCSE Computer Science 1.2.5, 1.2.6 and 1.2.7, covering syntax, logic and runtime errors, the bubble sort, merge sort, linear search and binary search, and evaluating an algorithm's efficiency.
- Identify the structural components of programs (constants, variables, initialisation, assignment, sequence, selection, repetition, iteration, data structures, subprograms, parameters, input/output) and write programs that use sequencing, selection, repetition (count-controlled, condition-controlled) and iteration with single entry and exit points.
A focused answer to Edexcel GCSE Computer Science 6.2, covering the structural components of programs and writing Python programs that use sequence, selection, count-controlled and condition-controlled repetition, and iteration.
Sources & how we know this
- Pearson Edexcel GCSE (9-1) Computer Science (1CP2) specification — Pearson (2020)