Home / Computer Courses / Error And Types Of Errors in C++ Language

Error And Types Of Errors in C++ Language

Error And Types Of Errors in C++ Language

Errors:

Error in a program known as bug. Bug is an abnormal condition that occurs due to any user mistake. The process of finding and removing bugs known as debugging. Different types of errors occur in C++ language .

errors and types of errors

Types of errors:

Types of errors are syntax errors, logical errors and run-time errors.

   1)   Syntax errors:

A syntax is the collection of rules for writing programs in programming languages. All statements that include in the program write according to these rules. Syntax errors occur when programmers do not write true syntax. These errors are also occur when an invalid statement writes in the program. The compiler detects the syntax error and show the reason of error to programmers. An syntax error program will never compiled successfully. There are many causes of syntax errors:

  • May be programmer miss to put delimiters.
  • A keyword write in wrong place.
  • May be programmer write a statement and miss to write the terminator at the end of statement.

Example:

coutt<<“Hello MyFSTech”;

Suppose programmer write the above statement. Here, error occur in ‘cout’ keyword.

   2)   Logical errors:

Logical errors are the type of error that occur due to the poor logic of the programmers. Due to the logical error, a program may produce unexpected or wrong output. These errors are not easily to find in the program because compiler cannot detects thee types of errors. These errors detect can only be examine the program. Cause of these errors are:

  • Using wrong formula. For example, programmer write a==3 instead of a!=3.
  • Using wrong condition in the program. For example, programmer want the sum of two numbers and write this sum=a-b.

 

Before Going Next, We Have Some Recommended for you!!!

 

It is time taking process to find these errors because:

  • Compiler cannot be detect these errors.
  • Programmer needs to review the whole program thoroughly.

   3)   Run-Time error:

Run-Time errors are the type of error that occur during the execution of the program. These errors occur when a statement is going to perform illegal operation. Run-Time errors detect and show by the compiler. If an error occurs then compiler stop the execution of the program and show the message. These errors normally occur due to the wrong input from user.

Example:

  • The may type wrong input like types an alphabet instead of an integer value.
  • It will occur if ans=num/n and user input the value of ‘n’ is 0.

About Shumaiza Asghar

Shumaiza Asghar

Check Also

Types of Identifiers with Examples in C/C++ Language

Types of Identifiers with Examples in C/C++ Language

What is Identifier, Types of Identifiers in C/C++ Language | MyFSTech.com The identifiers are the …

Leave a Reply

Your email address will not be published. Required fields are marked *