Examveda

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 2, k = 3;
    switch (i - k)
    {
    case -1:
        ++i;
        ++k;
        break;
    case 2:
        --i;
        ++k;
        break;
    default:
        i += 3;
        k += i;
        break;
    }
    Console.WriteLine(i + "\n" + k);
    Console.ReadLine();
}

A. 2 3 3

B. 3 2 3

C. 3 4 4

D. 5 10 10

Answer: Option C


Join The Discussion

Related Questions on Control Flow Statements in C Sharp