An algorithm is intended to display the names of the layers of the Earth's atmosphere in order of decreasing altitude, starting with the highest ('Exosphere') and ending with the lowest ('Troposphere').
The algorithm is represented below in pseudocode:
1 SUBROUTINE getLayerName(layers)
layers ← ['Troposphere', 'Stratosphere', 'Mesosphere',
2 'Thermosphere', 'Exosphere']
3 RETURN layers[k]
4 ENDSUBROUTINE
5
6 FOR i ← 5 TO 0 STEP 1
7 OUTPUT(getLayerName(i))
8 ENDFOR
Rewrite Line 1 and Line 6 to make the algorithm work as intended.
Line 1:
Line 6:
Practise AQA GCSE Computer Science Structured programming and subroutines (procedures and functions) with exam-style questions for GCSE Computer Science. 100 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.