adplus-dvertising
frame-decoration

Question

What will be the output of the C#.NET code snippet given below?

int val;
for (val = -5; val <= 5; val++)
{
    switch (val)
    {
        case 0:
            Console.Write ("CompSci"); 
            break;
    }
    
    if (val > 0)
        Console.Write ("B"); 
    else if (val < 0)
        Console.Write ("X");
}

a.

XXXXXCompSci

b.

CompSciBBBBB

c.

XXXXXCompSciBBBBB

d.

BBBBBCompSciXXXXX

Answer: (c).XXXXXCompSciBBBBB

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the C#.NET code snippet given below?