Program
testing and
debugging
Debugging
is the word for testing and then removing errors(getting rid of the bugs).
It means running the program you have written and fixing the parts
that do not work properly. There are three types of programming errors:
syntax errors,
run-time errors
and logic errors.
I)
Syntax errors
When writing programs,
we must observe strictly the grammatical rules of the programming language.
Syntax errors are the result of violating such rules in a program. The
program will not run if it contains syntax errors.Syntax errors may be
caused by typing mistakes or misuse of the language.
***Most
Pascal compilers locate syntax errors and produce an error messages. It
is therefore relatively easy to remove syntax errors. Once the incorrect
statement is located, simple inspection should reveal any errors, and we
can correct the mistake with the help of the error message.
II)
Run-time errors
Run-time errors occurs
while the program is running. They cause the program to terminate in the
middle of its run. They are not syntax errors because the program can be
compiled successfully.
An example of a run-time error is dividing a value by zero. When writing
the program, we must ensure that the divisor does not hold a zero value.
Another example is trying to read the value for an integer variable, when
the entered value is real value or a character string.
To reduce the chance of causing run-time errors, we can include error checking
routines to trap invalid data.
III)
Logic errors
Logic errors are the
result of either an incorrect algorithm or incorrect implementation of
an algorithm. Logic errors produce incorrect or unexpected results.
Logic errors are not easily detected since the program will run even through
they exist. We may not know of their existence until we discover erroneous
output results.
Therefore, the program must be tested thoroughly and carefully before it
is put into use. To detect logic errors, we need to try out the program
with different sets of test data and compare the program output with expected
results.
If logic errors are caused by incorrect algorithm, we have to start again
from the algorithm design phase.