adplus-dvertising
frame-decoration

Question

Predict the output for the following set of code :
static void Main(string[] args)
   {
       int i;
       for (i =-3; i <= 3; i++)
       {
           switch (i)
           {
           case 0:
               Console.WriteLine("zero");
               break;
           }
           if (i > 0)
               Console.WriteLine("A");
           else if (i < 0)
               Console.WriteLine("B");
       }
       Console.ReadLine();
   }

a.

B B zero A A A

b.

B zero A A A

c.

B B B zero A A A

d.

A A A zero B B B

Posted under C# programming

Answer: (c).B B B zero A A A

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Predict the output for the following set of code :