adplus-dvertising
frame-decoration

Question

Select the output for the following set of code :
static void Main(string[] args)
  {
      int i = 2, j = 4;
      switch (i + j * 2)
      {
      case 1 :
      case 2 :
          Console.WriteLine("1 and 2");
          break;
      case 3 to 10:
          Console.WriteLine("3 to 10");
          break;
      }
      Console.ReadLine();
  }

a.

3 to 10 will be printed

b.

1 and 2 will be printed

c.

The code reports an error as missing ; before :

d.

The code gives output as 3 to 10

Answer: (c).The code reports an error as missing ; before :

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

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