Friday, 17 October 2014

Types of Errors in C++ Programming Language


What is a Bug?

Ans: An error in the computer program is called as a Bug.

What is Debugging?

Ans: The Process of finding and removing bugs is known as debugging


Different types of errors can be occurred in c++ programming language. These errors may be context error, logical error and run time error.

1). Syntax Error

A collection of rules for writing program in programming language is known as syntax. All program statements are written according to these rules. Syntax error is a type of error that occur when an individual statements. The compiler detects the syntax errors and display a error message to describe the cause of the error. A compiler contain the syntax error cannot be compiled successfully.

There can be many cause of syntax error some of them are follows:

  • The statement terminator is missing at the end of statement.
  • A misspelled keyword.
  • Any of the delimiters is missing.
Example : Typing coutt instead of keyword cout

2). Logical Error

A type of error that occurs due to poor logic of the programmer is called logical errors. A statement with logical error may produce unexpected and wrong result in the program. Logical errors are difficult to find because translator detect these error. The logical error can be resolved by  examining the program the thoroughly.  Some of the causes are follows:


  • Using wrong conditions in program 
 Example: writing a < 5 instead of a >5.
  • Using wrong formula in the program 
These errors are very difficult to resolve because.
  • It cannot be detected by the compiler.
  • It does not crash the program. That is why it is difficult to detect.
  • The user need to review the whole program for finding out the error.
  • It may take lot of time for detecting the error.

3). Run Time Error

A type of error that occurs during the execution of program is known as run time error. It is caused when a statement directs the computer to execute an illegal operation
Example: dividing a number by zero
The run time error are detected and displayed by the computer during the execution. Run time errors are normally caused due to the wrong input from the user. The computer stops executing the program and displays error message if a run time error occurs.

  • The user may ask the program to open a file that does not exists.  
  • The user may enter wrong type of data.

No comments:

Post a Comment


*Write Your Comments With Names..!!!
*Dont Use Abusive And Spam Words...!!!!
*Spam Comments Will Be Deleted Imidetialy Upon Review..!!