Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 15

Arthur is installing a safety fence around a rectangular outdoor swimming pool area. The pool area is 12 metres long and 6 metres wide. One of the longer sides runs along an existing high brick wall, so fencing is not needed on that side.

The pseudocode for an algorithm that calculates the total length of fencing required is shown below.

Line 5 and Line 7 contain logic errors.

Identify the error in each line and construct new lines of pseudocode that will correct the errors.

1 SEND "Enter length: " TO DISPLAY
2 RECEIVE length FROM (INTEGER) KEYBOARD
3 SEND "Enter width: " TO DISPLAY
4 RECEIVE width FROM (INTEGER) KEYBOARD
5 SET totalLength TO 2 * length
6 SET totalWidth TO 2 * width
7 SET total TO totalLength * totalWidth
8 SEND "Fencing needed: " & total TO DISPLAY
LineErrorCorrection
Line 5
Line 7
[4]
Markscheme

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank