Sunday, December 15, 2013

ERRORS

No one is perfect, everyone commits some errors in one form or the other. Programming errors often remain undetected until an attempt for compiling or executing the program is made. Since errors prevent the program form being compiled or executed successfully, one should remove them before compiling and executing. 
Error is an  illegal operation performed by the user which results in abnormal working of the program. The common type of errors that can occur as:

  1. Syntax Error: These are those errors that occur when you violate the rules of writing C++ syntax. All these errors are detected by the compiler so it is also known as compiler errors. Some of the common compile time errors are missing semicolons at the end of statements, reference to an undeclared variables, wrong number or type of arguments passed to a function, etc. The errors are as follows:       a) The spelling of cout is written as cou.                                                                                             b) The cout statement statement does not ends with a semicolon.                                                         c) The program does not end with a closing brace ( } ).
  2. RUN TIME ERRORS: These errors occurs during program execution after successful compilation. Some common run time errors are division by zero (Divide Error), null pointer assignment, stack overflow, etc. These errors are difficult to find as the compiler does not point to the line at which this error occurs. The error message is displayed only after the execution with a wrong output.
  3. LINKER ERRORS: These errors normally occur when after compilation we link the different object files with main's object file using Ctrl+F9 key (Run). Some common linker errors are writing maid() instead of main(), any user-defined function is called but not defined, any standard built-in function (sqrt,cos, etc.) is called but its defination which is stored in library file which is not present. The linker must find the defination of the function called otherwise it will not create an executable file. To correct these errors return back to the program using F6 key.
  4. LOGICAL ERRORS (SEMANTIC ERRORS): Errors like semantic and execution errors are easier to find because they can just be located by generation of error messages on compilation or execution of a program but some programs do not provide desired output when certain input values are supplied to it. Such errors which provide incorrect output but appears to be error free are called logical errors.  These errors are often difficult to detect. The technique of finding and correcting this type of errors is called logical debugging. The Hit and Trial Method is one of the best method of finding logical errors.

No comments:

Post a Comment