What type of errors occurs when the program is asked to implement an impossible task such as dividing a number by zero?
Answer Details
Programming errors are generally grouped into three categories: syntax errors, runtime errors, and logical errors. Each occurs at a different stage of running a program.
Syntax errors happen when code breaks the grammar rules of the programming language (for example, a missing bracket or semicolon), and they are caught before the program even runs.
Runtime errors happen while the program is actually executing, when it is asked to carry out an operation that is impossible or invalid during that execution, such as dividing a number by zero, accessing a file that does not exist, or running out of memory.
Logical errors occur when a program runs without crashing but produces the wrong result because of a flaw in the reasoning or algorithm used.
Dividing by zero is mathematically undefined, so when a running program attempts it, the system halts that operation and reports the failure while the program is in progress. This mid-execution failure on an impossible task is the defining feature of a runtime error.
Exam tip: if an error happens only when the program is actually running and involves an operation that cannot be completed (like division by zero or a missing file), classify it as a runtime error rather than a syntax or logical error.