Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 3

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:

[3]
Markscheme

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)

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.

Question bank