Search code examples
c#.netfor-loopperfect-square

formula for finding a square of a number


I need to display the squares of the numbers 1-10 using a for loop. This is what I have so far. I don't know what I am missing. Any help would be much appreciated.

        for (int counter = 1; counter <= 10; counter++)
        {                          
            Console.WriteLine(counter * counter);                
        }
        Console.ReadLine();

Solution

  • Try this

        for (int counter = 1; counter <= 10; counter++)
        {          
                Console.WriteLine(counter*counter);
        }