Errors In C Program.

 

Errors:

Syntax Errors:

Errors that occurs when you violates the rules of writing C syntaxes are known as Syntax errors.This compiler errors indicates something must be fixed so that code can be compiled.

For example:

printf("%d",(x,y))

Correction: 

printf("%d",(x,y));        /* ; terminator is added*/

Runtime Errors:

Errors which occur during runtime or during execution of program(one-time) after successful execution of a program.

For example:

n=9;
div=n/0;            /* Wrong logic */

Solution: A number cant be divided by 0.


Linker Errors:

These errors occur when after the compilation we link the different object files with main obect.

For example:

using Main() instead of main().


Logical errors:

On compilation and execution of a program when desired output is not obtained when certain input values are given. These types of errors which provide incorrect output but appears to be error-free are called logical errors. 

For example:

i=0;
for(i=0;I<3;i++);                /* Terminator after loop */ 
{
print("LOOP")
}            


Semantic Errors:

These errors occur when statement written in the program is not meaningful to compiler.

For example:

a+b=c;    /* not meaningful to compiler*/

Corect statement: 

 c=a+b;

Post a Comment

0 Comments