Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 60

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