Examveda

What will be the output of the following C# code?
 static void Main(string[] args)
 {
     int i;
     i = 0;
     while (i++ < 5)
     {
         Console.WriteLine(i);
     }
     Console.WriteLine("\n");
     i = 0;
     while ( ++i < 5)
    {
        Console.WriteLine(i);
    }
    Console.ReadLine();
}

A. 1 2 3 4
1 2 3 4 5

B. 1 2 3
1 2 3 4

C. 1 2 3 4 5
1 2 3 4

D. 1 2 3 4 5
1 2 3 4 5

Answer: Option C


Join The Discussion

Related Questions on Control Flow Statements in C Sharp