05-09-2004, 05:34 AM
The MOD issue.
Several guys explained how MOD works, but failed to explain why Mango used it in the following code:He's got 100 values to print and wants to print 10 of them per row; that is, 10 of them across the page.
He needs to know each time he finishes printing 10 of them so he can do a PRINT to the next line or row. So he needs to know when the index number "i" is a multiple of 10. The easiest way to determine if the index is a multiple of 10 is to use the MOD function.
The instruction "IF i MOD 10 = 0 THEN PRINT"
means: if the value of i divided by 10 produces a remainder of zero, then print. Obviously, if I divide a number by 10 and the remainder is zero, then the number is a multiple of 10.
P.S. Your use of "IF i MOD 12 THEN PRINT" doesn't make any sense because you're only going to print 12 values anyway, based of the FOR above.
*****
Several guys explained how MOD works, but failed to explain why Mango used it in the following code:
Code:
FOR i = 1 TO 100
PRINT USING " ###"; table(i);
IF i MOD 10 = 0 THEN PRINT
NEXT i
He needs to know each time he finishes printing 10 of them so he can do a PRINT to the next line or row. So he needs to know when the index number "i" is a multiple of 10. The easiest way to determine if the index is a multiple of 10 is to use the MOD function.
The instruction "IF i MOD 10 = 0 THEN PRINT"
means: if the value of i divided by 10 produces a remainder of zero, then print. Obviously, if I divide a number by 10 and the remainder is zero, then the number is a multiple of 10.
P.S. Your use of "IF i MOD 12 THEN PRINT" doesn't make any sense because you're only going to print 12 values anyway, based of the FOR above.
*****