Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
Question 19

A software engineer writing the temperature-monitoring software shown in Figure 1 decided to refactor the code by implementing it as a subroutine called FindMax. Line 1 was removed, and the array temps was defined as a parameter of the subroutine, which now returns the value of max_temp.

Figure 1

1  temps ← [18.5, 19.2, 21.0, 17.8, 16.5, 20.1]
2  max_temp ← temps
3  i ← 1
4  WHILE i < 6
5      IF temps[i] > max_temp THEN
6          max_temp ← temps[i]
7      ENDIF
8      i ← i + 1
9  ENDWHILE

State two advantages of implementing this logic as a subroutine rather than keeping it as inline code.

[2]
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