The programmer should know the fact that there is very less
chances that a program will run perfectly in first time. It doesn’t matter how
nicely the designing is done and how much care is taken while coding. One can’t
say that the program would 100% error free. So the programmer has to make
efforts to detect and rectify any kind of errors that are present in the
program. But before detecting and removing errors it is much more necessary
that the programmer should know about the types of errors in programming. This article will
explain you about the types of errors in programming that must be taken care while writing
your program.
chances that a program will run perfectly in first time. It doesn’t matter how
nicely the designing is done and how much care is taken while coding. One can’t
say that the program would 100% error free. So the programmer has to make
efforts to detect and rectify any kind of errors that are present in the
program. But before detecting and removing errors it is much more necessary
that the programmer should know about the types of errors in programming. This article will
explain you about the types of errors in programming that must be taken care while writing
your program.
Also Read: 15 Common Errors in C and C++ Programming
Types of Errors in Programming
The types of errors are classified into four categories.
These are: syntax errors, logical errors, run-time errors and latent errors.
These are: syntax errors, logical errors, run-time errors and latent errors.
Syntax Errors
Any violation of rules and poor understanding of the
programming language results in syntax errors. The compiler can detect such
errors. If syntax errors are present in the program then the compilation of the
program fails and is terminated after showing the list of errors and the line
number where the errors have occurred. In some cases the line number may not
exactly indicate the correct place of the error. In some other cases, a single
syntax error can result in a long list of errors. Correction of one or two
errors in the program may remove the entire list of errors.
programming language results in syntax errors. The compiler can detect such
errors. If syntax errors are present in the program then the compilation of the
program fails and is terminated after showing the list of errors and the line
number where the errors have occurred. In some cases the line number may not
exactly indicate the correct place of the error. In some other cases, a single
syntax error can result in a long list of errors. Correction of one or two
errors in the program may remove the entire list of errors.
Run-time Errors
Runtime errors are the errors that occur during the
execution of the program. Some examples are, dividing by zero error,
insufficient memory for dynamic memory allocation, referencing an out-of-range
array element. These are not detected by compiler while compilation process. A
program with these kinds of errors will run but produce erroneous results or may
cause termination of program. Detection and removal of a run-time error is a
difficult task.
execution of the program. Some examples are, dividing by zero error,
insufficient memory for dynamic memory allocation, referencing an out-of-range
array element. These are not detected by compiler while compilation process. A
program with these kinds of errors will run but produce erroneous results or may
cause termination of program. Detection and removal of a run-time error is a
difficult task.
Also Read: 5 Tips to Become a Better Programmer
Logical Errors
As the name itself implies, these errors are related to the
logic of the program. Logical errors are also not detected by compiler and
cause incorrect results. These errors occur due to incorrect translation of
algorithm into the program, poor understanding of the problem and a lack of
clarity of hierarchy of operators. Consider following C statement:
logic of the program. Logical errors are also not detected by compiler and
cause incorrect results. These errors occur due to incorrect translation of
algorithm into the program, poor understanding of the problem and a lack of
clarity of hierarchy of operators. Consider following C statement:
if(a==b)
printf(“Equaln”);
When a and b are float types values, they rarely become
equal due to truncation errors. The printf call may not be executed at all. A statement
like while(a!=b) might create an infinite loop.
equal due to truncation errors. The printf call may not be executed at all. A statement
like while(a!=b) might create an infinite loop.
Latent Errors
Latent Errors are the ‘hidden’ errors that occur only when a
particular set of data is used. Consider below example:
particular set of data is used. Consider below example:
result = (a+b)/(c-d);
An error occurs only when c and d are equal because that
will make remainder zero (divide by zero error). Such errors can be detected
only by using all possible combinations of data.
will make remainder zero (divide by zero error). Such errors can be detected
only by using all possible combinations of data.
Many of programmers not aware of different types of errors in programming. So it is very informative blog for all. keep blogging.