Types of Errors
Types of Errors
Syntax errors
Syntax errors represent grammar errors in the use of the
programming language. Common examples are
Misspelled variable and functions names
Missing semicolons
Unmatched parentheses, square brackets, and curly
braces
Incorrect format in selection and loop statements
Syntax errors are the easiest to find and fix. Over the years,
compiler developers have worked hard to make compilers
smarter so that they can catch errors at compile time that
might otherwise turn out to be run time errors.
Runtime errors
A type of error that occurs during the execution of a
program is known as runtime error. Runtime errors may
crash your program when you run it.
Common examples are:
Try to divide by a variable that contains a value of 0
Trying to open a file that does not exist
There is no way compiler to know about these kinds of
errors when the program is compiled. Runtime errors are
common due to wrong input from the user.
Logic errors
Logic errors occur when a programmer implements the
algorithm for solving a problem incorrectly. A statement
With logical error may produce unexpected and wrong
results in the program. Common examples are:
Multiplying when you should be dividing
Adding when you should be subtracting
Opening and using data from the wrong file
Displaying the wrong massage