Loading, please wait...

A to Z Full Forms and Acronyms

Common Types Of Error In Programming

Jul 28, 2019 Errors, Type of Errors, C Programming, 2420 Views
In this article, we'll see all the Common Types Of Error In Programming languages.

During program code, there are some error occurs in it these errors are:-

1) Syntax Error:-

                                These errors are easiest to find because they are highlighted by the compiler. This type of error is caused by a violation of the grammar rules of the language like the syntax of the language is not respected. If the program has syntax error it can not be executed. The compilation phase of the program is not complete until any syntax error is present in the program. Common syntax error includes missing or missed; or}, missing return type for a procedure, missing or duplicate variable declaration or keyword is wrong, etc.

For example:-  

int main (int argc, char *argv[]){

                         printf( “hello world. \n”)

                         }

It should be:   

int main (int argc, char *argv[]){

                        printf(“hello world. “\n);

                      }

so, notice this missing colon inline 2. statements in c have to end with a semicolon otherwise it called syntax error.

2) Run Time Error:-

                                      These errors occur during the execution of the program. These are also called execution time error. These types of errors come when there is any mismatch of basic data type or reference of an array element. That falls outside its range. These errors are not detected by the compiler but when the program runs it will produce different results. The programmer has to detect, isolate & correct such error present in the program.

For example:- 

#include<stdio.h>
void main(){       
int n=9, div=0;
printf(“result =%d”, div);
}


Error:  wrong logic, the number is divided by 0, so this program abnormal.

               Correct method is:- div=n/0;

 

3) Logical Error:-

                         These errors are not detected by the compiler because there is some logical mistake done by the programmer. These errors occur due to poor understanding of the problem or lack of clarity of the hierarchy of operators. Such error cause incorrect result. For example:-

while(i=1)
{

     statement 1;

     statement 2:

     statement n;

}

Here, = = is used instead of = because here equality has to check not to assign 1 value to I here loop will execute infinite because the value of I never change still it is 1.

 

4) Latent Error:-

                               These are a hidden error that comes when some set of data will be used.

Example:- 

int (z+x)/(x-y);

An error occurs when the value of x & y are equal. The latent error can be detected only by using all possible combinations of test data.

                

A to Z Full Forms and Acronyms