Computer Science Canada Multiplication table |
Author: | Punde [ 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:
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. |
Author: | Tony [ Wed Feb 12, 2003 3:50 pm ] | ||
Post subject: | |||
basically you next a forloop inside another forloop like this
For each of 19 rows (for r) there will be 19 columns (for c). In that space we put the product of the row number * column number the put "" at the end of inside loop makes a new line so we move on to the next row. You'll be using nested loops in many of your future programs |
Author: | Punde [ Thu Feb 13, 2003 1:17 pm ] |
Post 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. |
Author: | Tony [ Thu Feb 13, 2003 1:49 pm ] | ||
Post 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.
|
Author: | Punde [ Thu Feb 13, 2003 1:55 pm ] |
Post subject: | |
Oh I see, Thank you very much |