Prime b

Prime b

  • NA
  • 810
  • 346k

Another loop !

Jan 4 2012 11:50 PM
The problem

Write a console-based application that displays every
integer value from 1 to 20, along with its squared value.

This is what I have done. All I am curious is if there another way to do it, other than while,do loops.

            double max = 20;
            double math, mathDouble;
            for (double x = 1; x <= max; ++x)
            {

                math = x * 1;
                mathDouble = math * math;
                Console.WriteLine("The number is {0}, the square root of that number is {1}", math, mathDouble);

Answers (3)