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++ 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 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);
}
}
# 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 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.