Skip to main content
EnglandComputer ScienceSyllabus dot point

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.

Generated by Claude Opus 4.89 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Sequence, selection and repetition
  3. Input, processing and output
  4. Variables, constants and data structures
  5. Reading flowcharts and pseudocode
  6. Try this

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 F=C×1.8+32F = C \times 1.8 + 32, 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

Sources & how we know this