Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# code?
static void Main(string[] args)
{
int i = 9 , j = 7;
switch (i – j + 3)
{
case 9: 7:
j += 6;
break;
case 5:
i -= 4;
break;
}
Console.WriteLine(i + “\n” + j);
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int i = 9 , j = 7;
switch (i – j + 3)
{
case 9: 7:
j += 6;
break;
case 5:
i -= 4;
break;
}
Console.WriteLine(i + “\n” + j);
Console.ReadLine();
}
a) 5 7
b) 9 13
c) Compile time error
d) 9 7

Answer: c
Explanation: Invalid expression’7:’ in case 9:7:.

Join The Discussion