Runtime errors

These are the errors caused by unexpected condition encountered while executing the code that prevents the code to compile. These can be null pointer references, array out-of-bound errors, etc.

Example:

C++
// C++ program to illustrate
// runtime error

#include <iostream>
using namespace std;

// Driver Code
int main()
{

    int a = 5;

    // Division by Zero
    cout << a / 0;
    return 0;
}
Java
// Java program to illustrate
// runtime error

public class Main {
    // Driver Code
    public static void main(String[] args) {

        int a = 5;

        // Division by Zero
        System.out.println(a / 0);
    }
}
Python3
# code
print("GFG")
# Python program to illustrate
# runtime error

# Driver Code
def main():
    a = 5

    # Division by Zero
    print(a / 0)

if __name__ == "__main__":
    main()
JavaScript
// JavaScript code to illustrate
// division by zero

// Driver Code
function main() {
    let a = 5;

    // Division by Zero
    console.log(a / 0);
}

main();

Below is the error produced by the above code:

Types of Issues and Errors in Programming/Coding

Where there is code, there will be errors

If you have ever been into programming/coding, you must have definitely come across some errors. It is very important for every programmer to be aware of such errors that occur while coding.

Table of Content

  • 1. Syntax errors: 
  • 2. Logical errors:
  • 3. Runtime errors:
  • 4. Time Limit exceeded error:

In this post, we have curated the most common types of programming errors and how you can avoid them.

Similar Reads

1. Syntax errors:

These are the type of errors that occur when code violates the rules of the programming language such as missing semicolons, brackets, or wrong indentation of the code,...

2. Logical errors:

These are the type of errors that occurs when incorrect logic is implemented in the code and the code produces unexpected output....

3. Runtime errors:

These are the errors caused by unexpected condition encountered while executing the code that prevents the code to compile. These can be null pointer references, array out-of-bound errors, etc....

4. Time Limit exceeded error:

Time Limit Exceeded error is caused when a code takes too long to execute and execution time exceeds the given time in any coding contest. TLE comes because the online judge has some restrictions that the code for the given problem must be executed within the given time limit....