C Programming Error Types – Runtime, Compile & Logical Errors

While writing c programs, errors also known as bugs in the world of programming may occur unwillingly which may prevent the program to compile and run correctly as per the expectation of the programmer.

Basically there are three types of errors in c programming:

  1. Runtime Errors
  2. Compile Errors
  3. Logical Errors

C Runtime Errors

C runtime errors are those errors that occur during the execution of a c program and generally occur due to some illegal operation performed in the program.

Examples of some illegal operations that may produce runtime errors are:

  • Dividing a number by zero
  • Trying to open a file which is not created
  • Lack of free memory space

It should be noted that occurrence of these errors may stop program execution, thus to encounter this, a program should be written such that it is able to handle such unexpected errors and rather than terminating unexpectedly, it should be able to continue operating. This ability of the program is known as robustness and the code used to make a program robust is known as guard code as it guards program from terminating abruptly due to occurrence of execution errors.

Compile Errors

Compile errors are those errors that occur at the time of compilation of the program. C compile errors may be further classified as:

Syntax Errors

When the rules of the c programming language are not followed, the compiler will show syntax errors.

For example, consider the statement,

int a,b:

The above statement will produce syntax error as the statement is terminated with : rather than ;

Semantic Errors

Semantic errors are reported by the compiler when the statements written in the c program are not meaningful to the compiler.

For example, consider the statement,


In the above statement we are trying to assign value of a in the value obtained by summation of b and c which has no meaning in c. The correct statement will be


Logical Errors

Logical errors are the errors in the output of the program. The presence of logical errors leads to undesired or incorrect output and are caused due to error in the logic applied in the program to produce the desired output.

Also, logical errors could not be detected by the compiler, and thus, programmers has to check the entire coding of a c program line by line.

Looking for a good book to learn c programming language? Check out C: The Complete Reference by Herbert Schildt

12 Responses

  1. pulkit
    pulkit September 23, 2013 at 1:35 pm | | Reply

    gud gud

  2. sandesh
    sandesh December 19, 2013 at 4:38 pm | | Reply

    concise n meaningful!

  3. bathiniramakrishna
    bathiniramakrishna December 30, 2013 at 2:48 pm | | Reply


  4. pratyusha
    pratyusha January 4, 2014 at 12:57 pm | | Reply

    not bad

  5. rajwinder sekhon
    rajwinder sekhon April 8, 2014 at 3:56 pm | | Reply

    please more detail for type of errors….. i like ur topic if is written by u

  6. sanam
    sanam May 21, 2014 at 7:02 pm | | Reply

    add some others errors

  7. Dexter
    Dexter June 3, 2014 at 8:11 pm | | Reply

    Really helpful! thanks for the effort people :)

  8. anant
    anant June 24, 2014 at 5:49 pm | | Reply

    Yap really good one…..
    This will surely help out me during my exam !!

  9. Ramakrishna
    Ramakrishna June 29, 2014 at 2:54 pm | | Reply

    really bad….

  10. ravi sankar
    ravi sankar August 7, 2014 at 9:53 am | | Reply

    Nice…this increase the depth in c…thank u.

  11. ashish
    ashish September 3, 2014 at 2:16 pm | | Reply

    errors , how they canbe identified

  12. ananth teja
    ananth teja September 17, 2014 at 9:17 am | | Reply

    Very useful…thank you…

Please comment with your real name using good manners.

Leave a Reply