Seneca

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.
  • The programs' outcome will not be as intended.
  • Logic errors 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.
  • The error happens in a selection statement.

Test yourself on Logic Errors

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

  • A program is translated. The translator shows this error:

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

    Is this error a logic error?

  • Pick the sentence that is true about a logic error.

  • How does a logic error differ from a syntax error when a program is run?

Practise this topic for free