Example of run-time error in C#

This example shows that how a run-time error causes termination of execution of the program. Run-time errors occur when the program is executed.
Let’s suppose the following code in C#.

private void RuntimeError()
   int a = 20;
   int b = 10;
   int c = 10;
   int x = a / (b - c);
   int y = a / (b + c);

Above code sample has correct syntax and this code does not generate any error during compilation.But when C# run-time tries to execute a division by zero (a / (b – c)), it generates an error condition which causes the program to stop after displaying an message(see below in the picture).

Run time error in programming

Run time errors are not detected by the compiler, because the code is syntactically correct.