You will run two small labs using the statements; discuss the attributes of the programs; and write your own program using the for-or while statements. This lab is part of your discussion grade for the unit.
Write a program that squares the numbers from 1 to 10 using a for or while statement. Afterwards, print the results to the screen. Discuss how you used the statements learned in the lab to complete your program in the discussion box for this unit.
Matthew Brown wrote:Another question, given yous statement of the problem: why 100 and not 10?
Matthew Brown wrote:anyway, what your current code is doing is multiplying all the squares of numbers between 0 and 99 inclusive, and writing out the final answer. However, since you start with zero, and 0*anything is still zero, the final answer is always going to be zero.
Campbell Ritchie wrote:That is what comes from coding before you have worked out the algorithm. Get some paper a pencil and an eraser (preferably a large one ) and write down how you plan to do that on paper. When you have it down to words of one syllable, then you will find it easy to turn into code.
Avery Jerauld wrote:But I have no idea how to square it.