1. Syntax, logic and run-time errors
A syntax error breaks the rules of the programming language, so the program cannot be compiled or run. A program with no syntax errors obeys the rules / grammar of the programming language.
A logic error is a fault in the algorithm or design: the program runs but does not give the expected output, for example a wrong operator or a wrong loop count.
A run-time error happens while the program runs, when it performs an illegal instruction or invalid operation, for example divide by zero or an endless loop.
Examiner insight
Worked example 13 marks
Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the program does not contain any syntax errors.
(i) State what her colleague means by “does not contain any syntax errors”.
(ii) Identify and describe one other type of error that the program may contain.
- 1
(i) The program obeys the rules / grammar of the programming language used. [1]
- 2
(ii) Type of error: logic error. [1]
- 3
Description: an error in the algorithm / design, so the program does not behave as expected, e.g. a wrong arithmetic operator. [1]