Oxford, Cambridge and RSA (OCR) GCSE Computer Science Paper 2 Practice

Question: 1 / 400

What term describes an error in a program that leads to incorrect results despite the program successfully running?

Syntax Error

Runtime Error

Logic Error

A logic error is an issue in a program where the code runs without any syntax errors or crashes, yet the results produced by the program are not what the programmer intended. This type of error indicates that the logic of the program is flawed, meaning that the algorithm used or the control flow is incorrect, even though the code itself is syntactically correct.

For example, if a program is designed to calculate the average of a set of numbers but mistakenly sums the numbers instead of dividing by the count, it will run without crashing but provide the wrong result. This showcases the nature of logic errors, as the program's structure and syntax do not violate any rules, but the underlying logic fails to deliver the desired outcome.

In contrast, syntax errors occur when there is a typo or incorrect use of language rules, which prevent the code from running at all. Runtime errors happen when the program encounters issues during execution, like trying to divide by zero. Compilation errors relate to problems that occur before the code can be run, specifically during the translation of source code into machine code. Thus, understanding the characteristics of these types of errors is crucial for debugging effectively.

Get further explanation with Examzify DeepDiveBeta

Compilation Error

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy