Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
Question 36

A software developer writing the search algorithm shown in Figure 1 decided to reorganise the code by creating it as a subroutine. Line 1 and Line 2 were removed, and both the array data and the variable target were redefined as parameters of the subroutine.

Figure 1

1  data ← [45, 12, 78, 34, 89]
2  target ← 78
3  found ← false
4  i ← 0
5  WHILE i < 5 AND found = false
6      IF data[i] = target THEN
7          found ← true
8      ELSE
9          i ← i + 1
10     ENDIF
11 ENDWHILE

State two reasons why the developer decided to write this search algorithm as a subroutine.

[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