Types of Errors in Programming

By | September 9, 2017

Let us understand the different types of errors in programming languages that we usually encounter daily. These programming errors are not specific to just C programming but are also valid for other programming languages.

There are several types of errors in programming that programmers usually encounter and we shall describe here the root cause of these C programming errors and their solutions.

Different types of errors in programming languages such as C, Java with their examples

There are primarily two types of programming errors:

  1. Run-time Errors
  2. Compile-time Errors

Run-time Errors

The runtime error is a type of programming error that is encountered during the program execution. It would not display the error while compiling the source code. in which the

When you hit the run button, the run-time error occurs and identifying a run-time error is usually difficult as compared to a compile-time error because here, you don’t get any kind of hints by the compiler (IDE).

This kind of error may produce irrelevant results in the output and thereby, giving you the wrong or unexpected results.

It will not give you the error in the error screen unlike compile-time errors and hence, it comparatively difficult to debug a run-time error.

Examples of Run-time Errors:

  1. Infinite Loop
  2. Memory De-allocation
  3. Datatype mismatch
  4. Logical errors
  5. Type-checking errors

Compile-time Errors

The compile-time errors are usually detected while the source code is being compiled to the object code.

Every programming language has some rules to be followed for the instruction to be properly interpreted by the compiler. Any violation of rules of the programming language results in syntax errors.

When you hit the compile button, the compiler takes in the complete source code as an input and then checks for the errors and displays all the errors in a single take.

It is easy to debug the compile-time errors as you get a brief description of the errors with the exact position of where the error was encountered.

So, it is much easier to debug as compared to the run-time errors. These run-time errors include the warnings and error messages.

Examples of Compile-time errors:

  1. Undeclared variable definitions
  2. Improper function prototyping
  3. Undeclared function definitions
  4. Semicolon, braces and other similar issues.
  5. Lvalue required as left operand

Let us have a look at some of the most common programming errors here. In the categories mentioned above, there are some specific programming errors mentioned below.


1. Syntax Errors

The syntax errors fall under the category of compile-time error. This error normally occurs when there’s any violation in the syntax of the programming language.

Every programming language has a set of specific rules about their data types, indentations, variables and function definitions, etc.

It is important to follow these syntax errors and keep the source code as accurate as possible to avoid these kinds of errors.

When the compiler detects any syntax errors, the compilation process is abnormally terminated and all the errors and warning messages are displayed by the compiler along with their line numbers and sometimes, also the solutions.

Examples of Syntax Errors:

  1. Missing semicolons
  2. Undeclared function definitions
  3. Undeclared variable definitions
  4. Improper expressions
  5. Improper function prototyping


2. Logical Errors

The logical error falls under the category of compile-time error. These errors usually are related to the logical approach defined by the programmer.

Incorrect order of evaluation of statements, wrong condition implementations are few of the reasons of these logical errors which are one of the most common types of errors in C programming.

The compiler does not usually detects these logical errors and gives you incorrect output results which could be confusing.

These errors are primarily due to a poor understanding of the problem, incorrect translation of the algorithm into the program and a lack of clarity of hierarchy of the operators.

Examples of Logical Errors:

  1. Incorrect Logic
  2. Improper Algorithm to code translation
  3. Miscalculations
  4. Infinite loops


3. Latent Errors

The latent errors fall under the category of run-time errors. These latent errors are hidden and get resolved only when you use different data sets for different scenarios.

The latent errors are also popularly known as Semantic errors. These kinds of programming errors are usually not recognized by the compiler and thereby, you don’t get the warnings and errors messages.

If b is zero here, you may get a divide by zero error here. To resolve this, you might have to change the value of b to different values, and identify which scenario gives you the expected results.

Examples of Semantic Errors:

  1. Divide by zero
  2. Array out of bounds



Let us know if you have any suggestions or any other types of errors in any programming language. Our comment section is open for you.

2 thoughts on “Types of Errors in Programming

  1. Vikram Jindal

    There is also one more type of error callwd as semantic error. Can you please describe about it as well?

  2. priya

    Runtime errors occur when a program with no syntax errors asks the computer to do something that the computer is unable to reliably do.


Let's Discuss