Structured programming and subroutines (procedures and functions)

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142
Question 37
Easy

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]

Structured programming and subroutines (procedures and functions) Questions

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