Types of Errors in C++


Types of Errors in C++

Errors may occur due to human mistakes. So errors arise either due to typing mistake or due
to illegal logic.

Mainly there are four types of errors :

  • Compiler error
  • Logical error
  • Linker error
  • Run time error

Compiler error :

Compiler errors are also called as syntax errors. These occurs either due to the typing
mistake in the syntax or by writing wrong syntax.

Example--suppose you not put semicolon after the statements then you will be having this
type of error.

Correct declaration :
int x;

Error :
int x //because we forgot to put semicolon.

Logical Error :

These are generally arise due to the invalid or wrong logic in the problem. This type of error
is related with the Run-time error.

Example :

If you applied a wrong logic in the if() or any other conditional/looping statement then you
will get a logical error.

or

If you divide a number by zero(also an Arithmetic exception).

Linker Error :

Sometimes program is correct with all the syntax and the logic is compiled successfully.
But during linking if prototypes are not properly declared then error will occur which is called
linking error.

Run-time error :

These occurs after the successfully execution of the program.

Example : If you divide a number by zero(also an Arithmetic exception).



     Prev                                                   NEXT

2 comments:

Anonymous said...

why the examples of logical nd run-time error are same..
it is confusing us..

Linda Lazarus said...

Understanding the types of errors in C++ is crucial for debugging code effectively. Tools like q Flipper can assist in identifying and resolving these errors quickly, enhancing the overall development process.

Post a Comment