Suggesting a correction

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Suggesting a correction

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Line 3 of a totalling algorithm is Total ← 5. Which is the better correction?
A Line 3 Total ← 5 is wrong because the total must start at 0. Change it to Total ← 0, so the answer is no longer 5 too high.
B Line 3 is wrong. The algorithm needs rewriting.
2. Line 4 is IF Mark > 50 THEN, but 50 should also count. Which correction is complete?
A Line 4 should be changed to make the program work better.
B Line 4 should be IF Mark >= 50 THEN, so a mark of exactly 50 is now counted.
3. The loop on line 2 is FOR Count ← 1 TO 9 but there are 10 numbers. Which explains the effect of the fix?
A Changing TO 9 to TO 10 makes the loop run faster.
B Changing TO 9 to TO 10 makes the loop run 10 times, so all ten numbers are processed.
4. True or false: writing 'Line 5 is wrong' is a full correction.
A False. You must also say why it is wrong and write the corrected statement.
B True. Naming the line is all that is needed.
5. Line 3 is WHILE Num <> 0 DO, but Num never changes inside the loop. Which correction is better?
A Add Num ← Num - 1 inside the loop, so the condition eventually becomes false and the loop stops.
B Line 3 is wrong because loops never end. Make the loop shorter.

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Line 3 should be Total ← 0 ANames the line but gives no reason and no replacement statement, and does not explain the effect on the output
2Line 5: change = to ← in Count = Count + 1 BQuotes the faulty line and replaces the comparison symbol with the assignment arrow
3Say why the line is wrong and give the corrected statement: the loop must stop at 10, not 11 CNames the faulty line and writes the replacement statement, so the totalling variable starts from zero
4Explain the effect of the fix: the loop now ends, so the program no longer repeats forever DLine 4 should be Number ← Number + 1 inside the WHILE loop
5The error is somewhere in the loop. Change it so it works. ELine 2 should be FOR Index ← 1 TO 10
6Line 6 is wrong. It should be fixed. FDoes not name the exact line or symbol, does not say why it is wrong, and gives no corrected statement

Definitions

Line 3 should be Total ← 0

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Faulty line 3: Total = 0 Correct line 3: Total _ 0 Why: assignment needs the arrow symbol
2.
Line 2 is wrong: Count is not set first Correction: Count ← _ Effect: the count starts from zero
3.
Faulty line 1: FOR Index ← 1 TO 9 Correct line 1: FOR Index ← 1 TO __ Effect: all 10 array items are processed
4.
Pass is 50 or more. Faulty: IF Mark > 50 Correct: IF Mark __ 50 THEN Effect: a mark of 50 now counts as a pass
5.
Faulty: the IF statement has no closing line Correction: add _____ after the last line Effect: the selection is now complete

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Total ← 0
B FOR Count ← 1 TO 5
C INPUT Mark
D Total = Total + Mark
E NEXT Count
F OUTPUT Total
Question 2
A Passes ← 1
B INPUT Mark
C IF Mark >= 50 THEN
D Passes ← Passes + 1
E ENDIF
F OUTPUT Passes
Question 3
A INPUT Age
B IF Age > 12 OR Age < 20 THEN
C OUTPUT "Teenager"
D ENDIF
Question 4
A Total ← 0
B FOR Count = 1 TO 5
C Total ← Total + Count
D NEXT Count
E OUTPUT Total
Question 5
A DECLARE Price : INTEGER
B OUTPUT "Price, e.g. 2.50"
C INPUT Price
D OUTPUT Price * 3

Answer Key

Suggesting a correction
Section A: Quick Questions
Q1
A — Line 3 Total ← 5 is wrong because the total must start at 0. Change it to Total ← 0, so the answer is no longer 5 too high.
Q2
B — Line 4 should be IF Mark >= 50 THEN, so a mark of exactly 50 is now counted.
Q3
B — Changing TO 9 to TO 10 makes the loop run 10 times, so all ten numbers are processed.
Q4
A — False. You must also say why it is wrong and write the corrected statement.
Q5
A — Add Num ← Num - 1 inside the loop, so the condition eventually becomes false and the loop stops.
Section B: Match the Pairs
Q1
Line 3 should be Total ← 0 → Names the faulty line and writes the replacement statement, so the totalling variable starts from zero
Q2
Line 5: change = to ← in Count = Count + 1 → Quotes the faulty line and replaces the comparison symbol with the assignment arrow
Q3
Say why the line is wrong and give the corrected statement: the loop must stop at 10, not 11 → Line 2 should be FOR Index ← 1 TO 10
Q4
Explain the effect of the fix: the loop now ends, so the program no longer repeats forever → Line 4 should be Number ← Number + 1 inside the WHILE loop
Q5
The error is somewhere in the loop. Change it so it works. → Does not name the exact line or symbol, does not say why it is wrong, and gives no corrected statement
Q6
Line 6 is wrong. It should be fixed. → Names the line but gives no reason and no replacement statement, and does not explain the effect on the output
Section C: Definitions
Q1
Line 3 should be Total ← 0 — To suggest a correction, name the wrong line or symbol, say why it is wrong, write the corrected statement, and explain what the fix changes in the algorithm's output.
Section D: Fill in the Blanks
Q1
Faulty line 3: Total = 0 Correct line 3: Total ← 0 Why: assignment needs the arrow symbol
Q2
Line 2 is wrong: Count is not set first Correction: Count ← 0 Effect: the count starts from zero
Q3
Faulty line 1: FOR Index ← 1 TO 9 Correct line 1: FOR Index ← 1 TO 10 Effect: all 10 array items are processed
Q4
Pass is 50 or more. Faulty: IF Mark > 50 Correct: IF Mark >= 50 THEN Effect: a mark of 50 now counts as a pass
Q5
Faulty: the IF statement has no closing line Correction: add ENDIF after the last line Effect: the selection is now complete
Section E: Spot the Error
Q1
D — Line 4 is wrong because = is a comparison, not an assignment. It should be Total ← Total + Mark. With the fix, each mark is added to the running total, so the output is the sum of all five marks.
Q2
A — Line 1 is wrong because the counter starts at 1, so it is one too high. It should be Passes ← 0. With the fix, the output is the true number of passes instead of always being one too many.
Q3
B — Line 2 is wrong because OR makes the condition true for every age. It should be IF Age > 12 AND Age < 20 THEN. With the fix, only ages 13 to 19 are output as Teenager.
Q4
B — Line 2 is wrong because a FOR loop sets its start value with the assignment arrow, not =. It should be FOR Count ← 1 TO 5. With the fix, the loop is valid and runs five times to total 1 to 5.
Q5
A — Line 1 is wrong because prices such as 2.50 have decimal places, which an INTEGER cannot store. It should be DECLARE Price : REAL. With the fix, the pence are kept and the output is correct.