adplus-dvertising
frame-decoration

Question

Select output for the following code:
static void Main(string[] args)
  {
      int i;
      int j = 1;
      int []ar = {21, 22, 13, 4};
      switch (ar[j])
      {
      case 1:
          i++;
          break;
      case 2:
          i += 2;
          j = 3;
          continue;
      case 3: 
         i %= 2;
         j = 4;
         continue;
      default: 
         --i;
      }
      Console.WriteLine(i);
      Console.ReadLine();
  }

a.

23

b.

15

c.

Compile time error

d.

12

Posted under C# programming

Answer: (c).Compile time error

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Select output for the following code: