adplus-dvertising
frame-decoration

Question

What would be the output of given code snippet?
public  static void Main(string[] args)
 {
     try
     {
         int a, b, c = 5;
         b = 0;
         a = c / b;
         Console.WriteLine("A");
     }
     catch (ArithmeticException e)
     {
         int c = 5;
         int i = 10;
         int z = 2 * c - i;
         Console.WriteLine("B");
         Console.WriteLine(z);
     }
     Console.ReadLine();
 }

a.

Compile time error

b.

Run time error

c.

B 0

d.

B

Posted under C# programming

Answer: (c).B 0

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What would be the output of given code snippet?