TESTING AND DEBUGGING


A mistake in a computer program is called a bug.
The process of eliminating bugs in a program is called debugging.

There are 3 kinds of programming errors:

  1. Syntax Errors
    • Results when your program contains codes that violate the grammar rules of the language
    • The compiler identifies syntax errors and issues an error message (or a warning message if the error is not too serious)
    • The compiler attempts to locate and report the location of the errors (usually accurate to within a few lines)
    • Error messages subsequent to the first one have a higher likelihood of being incorrect since it has to guess at what you meant to write down.

  2. Run-Time Errors
    • Are not detected at compilation
    • They are detected when the compiled program is run
    • A common example of a run-time error is an attempt to divide a number by zero

  3. Logic Errors
    • Logic errors can exist even when the program compiles and run without error messages.
    • Desktop checking is needed to detect the error
    • As an example let us consider the pea pod problem. If you mistakenly used division instead of multiplication when figuring out the total number of peas in the pea pods, the program will compile and run without messages, and yet the program does not give the correct result.