6.2: Reading Algorithms
Exam Board:
Eduqas / WJEC
Specification:
2016 +
Reading Algorithms
In an exam you may be asked to read an algorithm and prove your understanding, most commonly by listing the outputs.
Start from the first line and follow the program line by line, recording the value of variables as you go.
When you encounter a for loop, repeat the indented code as many times as stated in the range.
Example Algorithm:
Start NewProgram
number is integer
maxvalue is integer
input maxvalue
for i = 1 to maxvalue
output (i * i)
???????
output 'program finished'
End NewProgram
Example Questions:
1. List the outputs produced by the algorithm if the 'maxvalue' input is 5.
2. State the code that has been replaced by '???????' and what the code's purpose is.
Example Answers:
1.
Outputs:
1
4
9
16
25
program finished
2.
Missing Code: next i
Purpose: Moves the loop to the next iteration.
Watch on YouTube
Questo's Questions
6.2 - Reading Algorithms:
New & Updated Content coming very soon