Computer Science Canada

times table

Author:  WooFerPPK [ Tue Oct 01, 2002 7:01 am ]
Post subject:  times table

i have to make a program that displays a time table, now i need it to count from 12 to 1. i got this so far
code:

var gnumber : real 
put "Please enter the number"
get gnumber


for decreasing times : 12 .. 1
    locate (times, 1)
    put times, " * ", gnumber, " = ", times * gnumber
    delay (100)
end for


now i instead of it going like this
1
2
3

i want the numbers to go down like this
3
2
1

what am i doing worng?

Author:  Tony [ Tue Oct 01, 2002 9:14 am ]
Post subject: 

well here's your problem:
code:
locate (times, 1)


since you count downwards then it will first print on 12th line and go up.

what you can do is to set up a separate counter that will add 1 every time for loop starts.

code:
for decreasing times : 12 .. 1
line := line +1
    locate (line, 1)
    put times, " * ", gnumber, " = ", times * gnumber
    delay (100)
end for

Author:  WooFerPPK [ Tue Oct 01, 2002 11:32 am ]
Post subject: 

Thanks again tony


: