9.0b: Challenge Answers

Bronze

Print the numbers 500 through 525 using a for loop:

class Program
{
    static void Main(string[] args)
    {
        for (int i = 500; i <= 525; i++)
        {
            Console.WriteLine(i);
        }
    }
}

Silver

for (int i = 0; i <= 100; i += 5)
{
    Console.WriteLine(i);
}

Gold

for (int i = 1; i <= 100; i++)
{
    if (i % 15 == 0)
    {
        Console.WriteLine("FizzBuzz");
    }
    else if (i % 3 == 0)
    {
        Console.WriteLine("Fizz");
    }
    else if (i % 5 == 0)
    {
        Console.WriteLine("Buzz");            
    }
    else
    {
        Console.WriteLine(i);
    }
}

Next we will cover Classes and Objects

Last updated