Two different versions of a subroutine designed to simulate a chemical concentration C C\,C being repeatedly halved until it falls below 0.1 are shown in the pseudocode below.
SUBROUTINE decay(C)
val ← C
steps ← 0
REPEAT
val ← val / 2
steps ← steps + 1
UNTIL val < 0.1
OUTPUT steps
ENDSUBROUTINE
SUBROUTINE decay(C)
val ← C
steps ← 0
WHILE val >= 0.1
val ← val / 2
steps ← steps + 1
ENDWHILE
OUTPUT steps
ENDSUBROUTINE
Describe two differences in the way the loops in Subroutine X and Subroutine Y execute.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.