Debugging Notes
Debugging Notes
Program Testing means running the program, executing all its instructions/
functions
and testing the logic by entering sample data in order to check the output.
Debugging is
the process of finding and correcting the errors in the program code.
Type of errors: There are three types of errors generally occur during
compilation and
running a program. They are (i) Syntax error; (ii) Logical error; and (iii) Runtime
error.
1.Syntax error: Every programming language has its own rules and regulations
(syntax).
If we overcome the particular language rules and regulations, the syntax error
will
appear (i.e. an error of language resulting from code that does not conform to
the syntax
of the programming language). It can be recognized during compilation time.
Example
a=0
while a < 10
a=a+1
print a
In the above statement, the second line is not correct. Since the while statement
does not
end with „:‟. This will flash a syntax error
2.Logical error: Programmer makes errors while writing program that is called
„logical
error‟. It is an error in a program's source code that results in incorrect or
unexpected
result. It is a type of runtime error that may simply produce the wrong output or
may
cause a program to crash while running. The logical error might only be noticed
during
runtime, because it is often hidden in the source code and are typically harder to
find
and debug
3.Runtime error: A runtime error is an error that causes abnormal termination
of
program during running time. In general, the dividend is not a constant but
might be a
number typed by you at runtime. In this case, division by zero is illogical.
Computers
check for a "division by zero" error during program execution, so that you can
get a
"division by zero" error message at runtime, which will stop your program
abnormally.
This type of error is called runtime error.
Example
(a) A=10
B=0
print A/B
(b) During running time, if we try to open a file that does not exist in the hard
disk,
then it will create runtime error.