3
Answers

Another loop !

Ask a question
Prime b

Prime b

12y
1.5k
1
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)