Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 6

An algorithm is intended to display six chemical elements from a list in reverse order (starting with 'Carbon' and ending with 'Hydrogen'). However, the algorithm currently contains logic errors.

Figure 1

1  SUBROUTINE printElements(elements)
      elements ← ['Hydrogen', 'Helium', 'Lithium',
2                 'Beryllium', 'Boron', 'Carbon']
3      RETURN elements[idx]
4  ENDSUBROUTINE
5
6  FOR i ← 6 TO 0 STEP 1
7      OUTPUT(printElements(i))
8  ENDFOR

Rewrite line 1 and line 6 from Figure 1 to make the algorithm work as intended.

[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