Examveda

What will be the output of the following C# code?
{
    try 
    {
        int i, sum;
        sum = 10;
        for (i = -1 ;i < 3 ;++i) 
        {
            sum = (sum / i);
            Console.WriteLine(i);
        }
    }
    catch(ArithmeticException e) 
    {
        Console.WriteLine("0");
    }
    Console.ReadLine();
}

A. -1

C. -1 0

D. -1 0 -1

Answer: Option C


Join The Discussion

Related Questions on Exception Handling in C Sharp