Skip to content
IGCSE·Tuition
Computer Science · Lessons

Describe a correction rather than merely show code

Rewriting the whole program feels safe, but a question that says 'describe' wants the fault and the fix in words.

On this page
  1. What does a full description contain?
  2. Worked example
  3. The mistake to watch for
  4. Check yourself
  5. Where this leads next

A good description of a correction has four parts: where the fault is, what is wrong, why it causes the wrong result, and what to change. Code alone shows only the last part, and markers cannot tell whether you understood the fault or copied a line.

This lesson sits in the problem-solving explanations module. It follows from justifying test cases, because a failing test is how most faults are found.

What does a full description contain?

  1. Where: the line number or the statement, for example “line 6”.
  2. What is wrong: the exact thing, such as a wrong divisor, a wrong comparison, a missing statement or a wrong loop limit.
  3. Why it matters: the effect on the output, ideally with a value from the test data.
  4. The change: the smallest fix, in words, optionally with the corrected line.

Use evidence from the requirement: “the requirement says average of three numbers, but the code divides by 2”.

Worked example

Requirement: read three numbers and output their average.

1  Total ← 0
2  FOR Index ← 1 TO 3
3     INPUT Number
4     Total ← Total + Number
5  NEXT Index
6  Average ← Total / 2
7  OUTPUT Average

Test data 4, 6, 8 should give 6 (since 4 + 6 + 8 = 18 and 18 / 3 = 6). The program outputs 9.

Where: line 6.

What is wrong: Total is divided by 2, but three numbers were entered.

Why it matters: with the test data, 18 / 2 = 9, which is not the expected 6.

The change: divide by 3, the number of values read. A safer change is to divide by a variable that counts the entries, so the line still works if the loop limit changes. Corrected line: Average ← Total / 3.

Check the fix. With 4, 6, 8: 18 / 3 = 6. This matches the expected result.

The mistake to watch for

A weak answer is:

The program is wrong because the average is not right. Change it so it gives the right average.

It gives no line, no fault and no change. A second weak style rewrites all seven lines with a different structure, so the marker cannot see what was actually wrong.

The correction: “Line 6 divides Total by 2, but three values are entered, so the output for 4, 6, 8 is 9 instead of 6. Change the divisor to 3.”

Check yourself

1. This code should add the whole numbers 1 to 10 (the answer is 55), but it outputs 45. Describe the correction.

1  Total ← 0
2  FOR N ← 1 TO 9
3     Total ← Total + N
4  NEXT N
5  OUTPUT Total
Show answer

Line 2 has the wrong upper limit. The loop stops at 9, so 10 is never added, and the total is 1 + 2 + … + 9 = 45 instead of 55. Change the limit from 9 to 10: FOR N ← 1 TO 10.

2. The rule is “output Pass for a mark of 50 or more”. A mark of 50 gives no output. Describe the correction.

1  INPUT Mark
2  IF Mark > 50 THEN
3     OUTPUT "Pass"
4  ENDIF
Show answer

Line 2 uses >, which excludes 50, but the rule says “50 or more”. A mark of exactly 50 fails the test, so “Pass” is not output. Change > to >=: IF Mark >= 50 THEN.

3. The code should output the total cost of three item prices (5, 6 and 7, so 18) but outputs 7. Describe the correction.

1  Total ← 0
2  FOR I ← 1 TO 3
3     INPUT Price
4     Total ← Price
5  NEXT I
6  OUTPUT Total
Show answer

Line 4 assigns Price to Total instead of adding it, so each pass overwrites the previous value and only the last price, 7, remains. Change it to Total ← Total + Price so the prices accumulate: 5, 11, 18.

Where this leads next

Once you can describe a fix, learn to show why a program gives its output in connecting a trace with the final output. The restricted pseudocode trace trainer can help you test a fix before you describe it.

If you often spot the error but lose marks on how you explain the fix, our teachers can work through your wording in online one-to-one Computer Science tuition.

Questions people ask

When a question says 'describe how to correct the error', can I just write the correct line?

Sometimes the line earns a mark, but 'describe' usually needs words too. Name the line, say what is wrong, say what it should be and why. If you include the corrected line as well, label it clearly so the marker sees both.

Should I rewrite the whole program?

Rarely. A full rewrite hides which part was wrong and can introduce new errors. Point to the one line or condition that is at fault and describe the smallest change. A short targeted answer shows you have found the real problem.

How do I know what the fix should be?

Compare the actual output with the expected output from the requirement. The difference points to the fault. Then trace the suspect line with the test data. If the corrected version gives the expected output, the fix is justified.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If you find bugs quickly but your written fixes read as 'change it so it works', a one-to-one teacher can practise the four-part description with you until it comes naturally.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service