A delivery company has six delivery vans numbered from 0 to 5.
The number of packages currently loaded into each van is stored in an array named packages.
The index of the packages array represents the van number.
packages| Index | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| Data | 12 | 5 | 8 | 15 | 0 | 7 |
The following program is intended to calculate and output the total number of packages across all vans.
for index = 1 to 5
total = 0
total = total + packages[index]
next index
print(total)
When tested, the program is found to contain two logic errors.
Describe how the program can be refined to remove these logic errors.
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.