Debugging in C++

Default Image

Different type of errors may occur in C++
programme. These errors called bugs. The process of finding and removing
these errors called debugging. There are three types of errors that may
occur in a programme:

  • Syntax errors
  • Logical errors
  • Runtime errors


Syntax errors


Syntax called the rules that are defined
to write to write a programme in a computer language. These rules are
meant to be followed exactly. In case if we skip any syntax rule the
translator programme will show an error that will be called syntax
error. Translator programme never translate a source code into machine
code if there is any syntax error until it removed. Common causes that
create a syntax error are:


*        Use a variable in programme without declaration.


*        Misspelling a variable/function name or using the case of the letters inconsistently.


*        Missing a semicolon in the end of statement.


*        Incorrect number of braces/delimiters {,}.


Logical errors


The errors in the logic of a programme is
called logical error. C++ compiler cannot detect a logical error itself
because it compiled and executed successfully. To remove such errors
programmer needed to view whole source code once again thoroughly. This
type of errors may occur when:


           *        Use a variable in a loop without initialization


          *        Setting a variable to an uninitialized value


          *        Using a single equal sign to check equality


          *        Extra Semicolons in a loop


          *        Forgetting a break in a switch statement


          *        Overstepping array boundaries


          *        Misusing the && and || operators


Runtime errors


An error occurred during execution of a
programme is called runtime error. A program crash is the most visible
type of runtime error, since the program suddenly quits while running.
Crashes can be triggered by memory leaks or other programming errors.
Common examples include dividing by zero, referencing missing files,
calling invalid functions, or not handling certain input correctly.

Read Count: 3 times

Comments

No comments yet.

Leave a Comment