What will be the output of the following C# code?

static void Main(string[] args)
{
    int x = 0;
    do
    {
        x++;
        if (x == 5)
        {
            x++;
            continue;
            break;
        }
        Console.WriteLine(x + " ");
    }
}while (x < 10);

a) 1 2 3 4 5
b) 10
c) 5 6 7 8 9 10
d) 1 2 3 4 5 6 7 8 9 10

1 thought on “What will be the output of the following C# code?”

  1. d
    Explanation: The condition will print the numbers from 1 to 10 when x == 5 and when x does not satisfy if condition until x < 10.
    Output:
    1 2 3 4 5 6 7 8 9 10

Leave a Comment