adplus-dvertising
frame-decoration

Question

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

a.

0

b.

0 5

c.

0 -10

d.

Compile time error

Posted under C# programming

Answer: (c).0 -10

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the following set of code?