Types of Errors

View


In any C program, there may be any three types of errors. They are-

  1. Syntax Errors
  2. Logical Errors
  3. Runtime Errors

Syntax Errors - Errors that occur when you violate the rules of writing C syntax are known as syntax errors. These errors indicate something that must be fixed (corrected) before the code can be compiled. All these errors are detected by compiler and thus are also known as compile-time errors. Example-

  • Missing Semi colon ( ; )
  • Missing parentheses  ( } )
  • Using variable without declaring it.
  • Spelling of pre-defined functions is wrong. Etc.

 Logical Errors - On compilation and execution of a program, desired output is not obtained when certain input values are given. These types of errors which provide incorrect output but appear to be error free are called logical errors. These are one of the most common types of errors done by beginners of programming.
These errors solely depend on the logical thinking of the programmer. Example-

  • Mistake in formula
  • Mistake in logic
  • Mistake in sequence of steps Etc.

Run time Errors - Errors which occur during program execution (run-time) after successful compilation are called run-time errors. One of the most common run-time error is division by zero also known as Division error. These types of error are hard to find as the compiler doesn’t point to the line at which the error occurs. Example-

  • Divide by zero
  • Insufficient memory space Etc.


Last modified: Tuesday, 21 September 2021, 9:41 AM