Introduction to Programming – Errors

Errors are the mistakes or faults in the program that causes our program to behave unexpectedly and it is no doubt that the well versed and experienced programmers also makes mistakes. Programming error are generally known as Bugs and the process to remove bugs from program is called as Debug/Debugging.

There are basically three types of error:

  1. Compilation error or Syntax error
  2. Runtime error or exception
  3. Logical error

Compilation error

Compilation errors are the most common error occurred due to typing mistakes or if you don't follow the proper syntax of the specific programming language. These error are thrown by the compilers and will prevent your program from running. These errors are most common to beginners. It is also called as Compile time error or Syntax error. These errors are easy to debug.

Example: Typing int as Int

Runtime error

Run Time errors are generated when the program is running and leads to the abnormal behavior or termination of the program. The general cause of Run time errors is because your program is trying to perform an operation that is impossible to carry out.

Example: Dividing any number by zero, Accessing any file that doesn't exist etc are common examples of such error.

Logical error

Logical error will cause your program to perform undesired operations which you didn't intended your program to perform. These errors occur generally due to improper logic used in program. These types of errors are difficult to debug.

Example: Multiplying an uninitialized integer value with some other value will result in undesired output.

Write your doubts or suggestion. I will try my best to help. You must escape source code before commenting. To format your source code paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>