Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
Question 34

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