The placement of braces is important:
Console.WriteLine("Number Square");
Console.WriteLine("-------------------");
for (counter = 1; counter <= maxValue; counter++)
{
square = counter * counter;
Console.WriteLine("{0} {1}", counter, square);
}
Note: It's good practice to always use enclosing braces for for
loops and if
statements precisely for this reason.
Also note that ^
is not 'to the power of' but exclusive OR