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

static void Main(string[] args)
{
    int i = 1, j = 5;
    do
    {
        Console.WriteLine(i = i++ * j);
    }while (i <= 10);
    Console.ReadLine();
}

a) 5 10 15 20 25 30 35 40 45 50
b) 5 25
c) 5 11 16 21 26 31 36 41 46 51
d) 5 30

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

  1. b
    Explanation: For first step of loop i = 1 .So, i++ * j = 1 * 5 = 5. For second step of loop i = 5, j = 5. So, i++ * j = 25. As, i = 25 hence, 25 >=10 loop condition breaks.
    Output:
    5 25.

Leave a Comment