Monday, August 24, 2015

Bugs in Programming

Bugs in Programming
Bug’s is an unexpected defect, fault, flaw or imperfections. In programming jargon, “errors” are known as “bugs”. Debugging is the name that programmers give to the activity of locating and removing errors from programs (once the errors are known to exist, from testing the program).

Programming errors or bugs are fall into three categories.
i.                   Syntax or compilation errors
ii.                 Logical errors or Semantic errors
iii.              Run-time errors

Syntax Errors
Syntax errors are grammatical mistakes. These errors are the easiest to find because they are highlighted by the compiler. Error messages are given. These errors are caused by the failure of the programmer to use the correct grammatical rules of the language Syntax errors are detected, and displayed by the complier as it attempts to translate your program. If a program has a syntax error it cannot be translated, and the program will not be executed.

The compiler tries to highlight syntax errors where there seems to be a problem, however, it is not perfect and sometimes the compiler will indicate the next line of code as having the problem rather the line of code where the problem actually exists.
Forgetting to close the message to printf ( ) with a double quote, omitting the semicolon at the end of each C statement, incorrectly typing the letter O for the number zero (0), or vice versa are some common syntax errors made by all beginning C programmer.

Logical errors
These are the hardest errors to find as they do not halt the program. They arise from faulty thinking on behalf of the programmer. They can be very troublesome. These are mistakes in a program’s logic. Programs with logic errors will often compiled, execute and output result. However, at least some of the time the output will be incorrect. Error message will not appear in case of logic errors, this makes logic errors very difficult to locate and correct.

Run-Time errors
As the name suggests run-time errors occurs at run time when the user directs the computer to perform an illegal operation, e.g.:
      Dividing a number by zero
      Assigning a variable to the wrong type of variable

When a run-time error occurs, the computer stops executing the program, and displays a diagnostic message that indicates the line where the errors occurred. 

No comments:

Post a Comment