Complete the table showing all of the outputs from the subroutine call evaluate(11)
The first output has already been written in the trace table. You may not need to use all rows of the table.
SUBROUTINE evaluate(a)
OUTPUT a
WHILE a > 6
IF isMultipleOfThree(a) = True THEN
a ← subtractFour(a)
ELSE
a ← addOne(a)
ENDIF
OUTPUT a
ENDWHILE
ENDSUBROUTINE
SUBROUTINE subtractFour(n)
result ← n - 4
RETURN result
ENDSUBROUTINE
SUBROUTINE addOne(n)
result ← n + 1
RETURN result
ENDSUBROUTINE
SUBROUTINE isMultipleOfThree(n)
IF (n MOD 3) = 0 THEN
RETURN True
ELSE
RETURN False
ENDIF
ENDSUBROUTINE
| Output |
|---|
| 11 |
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.