An algorithm is intended to display eight planets of the Solar System from a list in reverse order (starting with 'Neptune' and ending with 'Mercury'). However, the algorithm currently contains logic errors.
Figure 1
1 SUBROUTINE getPlanet(planets)
planets ← ['Mercury', 'Venus', 'Earth', 'Mars',
2 'Jupiter', 'Saturn', 'Uranus', 'Neptune']
3 RETURN planets[pos]
4 ENDSUBROUTINE
5
6 FOR j ← 8 TO 0 STEP 1
7 OUTPUT(getPlanet(j))
8 ENDFOR
Rewrite line 1 and line 6 from Figure 1 to make the algorithm work as intended.
131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.