Logic Errors

Computer Science: KS3, topic 2.1.20

Logic Errors

Logic errors are hard to detect because the translator will not detect them for us.

Logic errors

Logic errors

  • Logic errors are mistakes in the logic of the program.
  • Programs will run, but their outcome will not be as intended.
  • They are much more difficult to debug than syntax errors.
Examples of logic errors:

Examples of logic errors:

  • Many logic errors arise from the use of the wrong boolean operator, e.g. mixing up AND and OR.
  • Many logic errors arise from putting menu options the wrong way around in a selection statement.

Test yourself on Logic Errors

  • Why is it more difficult to detect a logic error than a syntax error?

  • You translate a program and see this error:

    ERROR LINE 13 "x = True NOT False" Incorrect use of operator

    Is this a logic error?

Practise this topic for free