CSharp - What is the output: use brackets for your if-else blocks?

Question

What is the output of the following code?

using System;

class Program
{
        static int score;

        static void Main(string[] args)
        {
            int number = 5;
            if (number % 2 == 0)
                Console.WriteLine("{0} is an even number", number);
                Console.WriteLine("We have not used brackets for if statements");
            else
                Console.WriteLine("{0} is an odd  number", number);

        }
}


Click to view the answer

Compilation error.

Note

It is a good practice to use brackets for your if-else blocks.

You need to rewrite the section as follows:

int number = 5;
if (number % 2 == 0)
{
    Console.WriteLine("{0} is an even number", number);
    Console.WriteLine("We have not used brackets for if statements");
}

else
    Console.WriteLine("{0} is an odd  number", number);