Multiplication table
Author 
Message 
Punde

Posted: Wed Feb 12, 2003 2:56 pm Post subject: Multiplication table 


Hello there,
I just joined this forum because I think it will help me a lot in Turing, which is what I am learning at the moment, anyways I have a question.
I am trying to do a multiplication table that displays the multiplication numbers from 1 to 19, however I don't know how to actually multiply them using for loops.
I have the following code:
code: 
setscreen ( "text:25;90" )
put " "..
for i:1..19
put i:4..
end for
put ""
put repeat ("", 82)..
put ""
for a: 1..19
put a:4, ""
end for

THe table has to look something like this:
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1 1 2 3
2 2 4
3 3
4 4
5
6
7
8
9
...
and so on. Can anyone please help me with this? Thanks.






Sponsor Sponsor



Tony





Punde

Posted: Thu Feb 13, 2003 1:17 pm Post subject: (No subject) 


Thanks, but with the code you gave me I only get the actual multiplication but not the numbers on the top with the , nor the line on the left with the . Can you help me with this little part?? Thx.






Tony

Posted: Thu Feb 13, 2003 1:49 pm Post subject: (No subject) 


for that you can use your own code...
there shouldn't be any probem of adding the top part to it. Just copy your code and place it in front of nested loops.
Now if you do a little modification to the nested loops, you can also draw a vetrical line in font of the table.
paste a line of code to put the numbers and  right after for r:1..19
where R would be your number.
code: 
%YOUR CODE PART BELOW
put " "..
for i:1..19
put i:4..
end for
put ""
put repeat ("", 82)..
%MY CODE PART BELOW
for r:1..19
put r:4,"".. %< add this
for c:1..19
put r*c:4, ""..
end for
put ""
end for


Tony's programming blog. DWITE  a programming contest. 




Punde

Posted: Thu Feb 13, 2003 1:55 pm Post subject: (No subject) 


Oh I see, Thank you very much







