Cambridge IGCSE Computer Science 0478
Data Representation
Data Transmission
Hardware
Software
The Internet and Its Uses
Automated and Emerging Technologies
Algorithm Design and Problem-Solving
Programming
Algorithm Design and Problem-Solving
Finding errors and writing algorithms
- 3 things to know
- Paper 2
Overview
Syntax and logic errors, spotting and correcting mistakes in algorithms, and writing precise pseudocode.
What you need to know
Answer each one before you reveal it.
What is a syntax error?
What is a logic error?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is a syntax error?
Model answer
A syntax error breaks the grammar rules of the language, such as a misspelt keyword, so the code cannot be translated.
- 2
What is a logic error?
Model answer
A logic error makes the program run but give the wrong result, such as using < instead of <=.
- 3
How would you correct a loop that should run 10 times but runs 9 times?
Model answer
Change the loop condition, for example from Count < 10 to Count <= 10, so the final value is included.
- 4
Why might an algorithm that finds the largest of a set of numbers fail if the maximum is first set to 0?
Model answer
If every number is negative, none of them is larger than 0, so the algorithm wrongly outputs 0.
- 5
Why must a total be set to zero before a loop and not inside it?
Model answer
A total reset inside the loop loses the values added on earlier passes, so the result is wrong.
- 6
Why must conditions in algorithms be written precisely?
Model answer
A computer needs exact instructions, so x > y is acceptable but the words x is greater than y are not.
Other ways to work this
The same content, four other ways.
Everything in your subscription
Runs, plus a mode for every other kind of session.
Every question in Algorithm Design and Problem-Solving, on a schedule.
Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.