Computer Science Canada

loop program

Author:  hpdudette [ Tue May 27, 2003 6:18 pm ]
Post subject:  loop program

how do i make a loop program so that in one loop from 1 to 80 the out put the number and square the number and display it like this:
Num Square Num Square Num Square Num Square
1 1 21 441 41 1681 61 3721
2 4 22 484 42 1764 62 3864
continue through
20 200 40 1600 60 3600 80 6400

Author:  Blade [ Tue May 27, 2003 6:33 pm ]
Post subject: 

i think this is what you want.... but i dont know how you want it displayed because that confused the hell outta me trying to read that question. plz try to be more clear lol or organize your data correctly
code:

for i:1..20
put i, " ",i*2
end for

Author:  krishon [ Tue May 27, 2003 6:33 pm ]
Post subject: 

is this wut u want?

code:
for i : 1..80
    put (i), " "..
    put (i**2), " "..
    delay (30)
end for

Author:  Blade [ Tue May 27, 2003 6:53 pm ]
Post subject: 

haha i beat you Very HappyVery HappyVery HappyVery Happy

Author:  hpdudette [ Tue May 27, 2003 6:54 pm ]
Post subject: 

sorry bout that the output should look like the attachment

Author:  Tony [ Tue May 27, 2003 6:58 pm ]
Post subject: 

so its
code:

for c:1..3
for r:1..20
locate(r,c*10)
put r+c*20
end for
end for

Author:  hpdudette [ Tue May 27, 2003 7:14 pm ]
Post subject: 

thanks for your help u guys but its not suppose to look like that ... can n/e one else help

Author:  Asok [ Tue May 27, 2003 7:20 pm ]
Post subject: 

to be totally fair, you should be able to do the spacing yourself, you've been given the methods to find the values, you can figure out how to format it into whatever way you want. I'm not saying this to be mean but come on, at least try.

Author:  void [ Tue May 27, 2003 8:00 pm ]
Post subject: 

i agree with asok...but i couldnt help feeling sorry for u...so i decided to get you started...the first 2 colums of stuff has been done....just use the same pattern to do the spacing...its little programs like this that end up helping you understand the easy crap so that in the future with major programs, you can focus on the harder shit
code:

locate (1, 1)
put "NUM"
for a : 1 .. 20
    locate (a + 1, 1)
    put a : 3
end for
locate (1, 7)
put "SQUARE"
for a : 1 .. 20
    locate (a + 1, 10)
    put a ** 2 : 3
end for


: