6.2: Reading Algorithms
Eduqas / WJEC
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.
number is integer
maxvalue is integer
for i = 1 to maxvalue
output (i * i)
output 'program finished'
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.
Missing Code: next i
Purpose: Moves the loop to the next iteration.
Watch on YouTube
6.2 - Reading Algorithms:
New & Updated Content coming very soon