2.3.6

Error Types

Test yourself

Types of Errors

Illustrative background for Syntax errorsIllustrative background for Syntax errors ?? "content

Syntax errors

  • A syntax error is a mistake in the way the code is written.
  • It is similar to a spelling or grammar mistake in English.
  • Syntax errors prevent programs from running as a translator needs code to be syntactically correct.
  • Syntax errors are some of the easier bugs to fix in a broken program.
Illustrative background for Examples of syntax errorsIllustrative background for Examples of syntax errors ?? "content

Examples of syntax errors

  • prnt("Hello, world!");
    • Incorrect subroutine identifier.
  • newbalance = newBalance * 1.05;
    • Wrong capitalisation in variable identifier.
  • myBoolean = True NOT False;
    • NOT does not take two operands.
Illustrative background for Logic errorsIllustrative background for Logic errors ?? "content

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.
  • Logic errors are hard to detect because the translator will not detect them for us.
Illustrative background for Examples of logic errorsIllustrative background for Examples of logic errors ?? "content

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.
Illustrative background for Runtime rrrorsIllustrative background for Runtime rrrors ?? "content

Runtime rrrors

  • Runtime errors are errors that happen while the program is running.
  • Runtime errors cannot be found during translation.
  • These errors can only be detected while a program is running.
  • The chance of experiencing a runtime error can be reduced through testing.
  • Runtime errors are the trickiest of the three types of errors because they are not always found during development. Software users may first encounter runtime errors.
Illustrative background for Examples of runtime errorsIllustrative background for Examples of runtime errors ?? "content

Examples of runtime errors

  • Bad inputs that throw an unhandled exception.
  • Receiving unexpected or corrupted data.
  • Running out of memory.

Jump to other topics

1Computer Systems

1.1Systems Architecture

1.2Memory & Storage

1.3Computer Networks, Connections & Protocols

1.4Network Security

1.5Systems Software

1.6Ethical, Legal, Cultural & Environmental Concern

2Computational Thinking, Algorithms and Programming

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson