What Will Be The Output Of The Following C Codep Pre Langcsharp #105
What will be the output of the following C# code?</p> <pre><code class="language-csharp" line="1"> 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(); } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Looping Statements - Switch Statements - Quiz No.1.
What will be the output of the following C# 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(); }
3 to 10 will be printed
1 and 2 will be printed
The code reports an error as missing ; before :
The code gives output as 3 to 10