Structured programming and subroutines (procedures and functions)

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142
Question 35
Easy

State how many times the subroutine FLASH_LIGHT will be called with the parameter 'red' if the user input is 'medium' in Figure 1.

Figure 1

1      alert_level ← USERINPUT
2      IF alert_level = 'low' THEN
3          repeats ← 2
4      ELSE IF alert_level = 'medium' THEN
5          repeats ← 5
6      ELSE IF alert_level = 'high' THEN
7          repeats ← 8
8      ELSE
9          OUTPUT 'unknown alert level'
10     ENDIF
11     FOR i ← 1 TO repeats
12         IF i <= 2 THEN
13             FLASH_LIGHT('blue')
14         ELSE
15             FLASH_LIGHT('red')
16         ENDIF
17     ENDFOR
[1]

Structured programming and subroutines (procedures and functions) Questions

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