Mark As Completed Discussion

Let's test your knowledge. Click the correct answer from the options.

What is the output of the following code?

TEXT/X-CSHARP
1for (int i = 1; i <= 10; i++)
2{
3    if (i % 2 == 0)
4    {
5        Console.WriteLine(i);
6    }
7}
  1. 1, 3, 5, 7, 9
  2. 2, 4, 6, 8, 10
  3. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  4. None of the above

Click the option that best answers the question.