Runtime Errors
This type of error occurs while the program is running. Because this is not a compilation error, the compilation will be completed successfully.
These errors occur due to segmentation fault when a number is divided by division operator or modulo division operator.
Example: Let us consider an array of length 5 i.e. array[5], but during runtime, if we try to access 10 elements i.e array[10] then we get segmentation fault errors called runtime errors. Giving only an array length of 5
C++
// C++ program to demonstrate // a runtime error #include <iostream> using namespace std; int main() { int array[5]; return 0; } |
But in output trying to access more than 5 i.e if we try to access array[10] during runtime then we get an error.
Output:
Segmentation fault
C++ Program to Show Types of Errors
In any programming language errors is common. If we miss any syntax like parenthesis or semicolon then we get syntax errors. Apart from this we also get run time errors during the execution of code. In a similar way the errors are classified as below:
- Syntax Errors
- Runtime Errors
- Logical Errors
- Linked Errors
- Semantic Errors