CSharp - What is the output: runtime exception?

Question

What is the output of the following code?

using System;

class Program
{
    static void Main(string[] args)
    {
        int a = 100, b = 0;
        int c = a / b;
        Console.WriteLine(" So, the result of a/b is :{0}", c);
        Console.ReadKey();
    }
}


Click to view the answer

System.DivideByZeroException: 'Attempted to divide by zero.'

Note

The following program will compile successfully but it will raise an exception during runtime because we have overlooked the fact that the divisor (b) is 0.

Related Quiz