A computer science student has written a block of pseudocode to find the minimum atmospheric pressure recorded during a weather balloon flight from an array of 6 sensor readings.
1 pressures = [1013, 998, 985, 1002, 991, 1007]
2 lowest = pressures
3 idx = 1
4 WHILE idx <= 6
5 IF pressures[idx] < lowest THEN
6 pressures[idx] = lowest
7 ENDIF
8 idx = idx + 1
9 ENDWHILE
10 OUTPUT "Lowest pressure: " + lowest
Line 4 and Line 6 contain errors.
Identify the error in each line and construct new lines of pseudocode that will correct the errors.
| Line Number | Error | Correction |
|---|---|---|
| Line 4 | ||
| Line 6 |
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.