On 02/11/2010 18:22, Tony Firshman wrote:
Rich Mellor wrote, on 03/11/2010 17:49:
On 02/11/2010 17:34, Tony Firshman wrote:
10 FOR j = 1 TO 100
15 sp$ = " ";
20 PRINT j;
20 if j/3 == int(j/3)
25 sp$="";
30 PRINT " FIZZ";
40 END IF
30 IF j/5 == int(j/5)
40 PRINT sp$&"BUZZ";
50 END IF
60 PRINT
70 END FOR
Hi Tony,
Yes, you are going to confuse SB programmers with that one -
corrected version and (improved) is:
10 FOR j = 1 TO 100
15 sp$ = " "
20 PRINT j;
20 IF j/3 = int(j/3) : sp$="": PRINT " FIZZ";
30 IF j/5 = int(j/5): PRINT sp$&"BUZZ";
40 PRINT
50 END FOR j
You can also use
20 IF j MOD 3=0 : sp$="": PRINT " FIZZ";
30 IF j MOD 5=0: PRINT sp$&"BUZZ";
He he - I also had to remove brackets in the IF clause.
I always forget the perl equiv operator as well as it changed from
earlier versions.
The core logic though was fine - phew.
... but there are also two line 20s!
Tony
By the way Tony,
Have you built a time machine in one of your sheds? Just your messages
seem to be sent a whole day before the message they are responding to!
--
Rich Mellor
RWAP Services
http://www.rwapsoftware.co.uk
http://www.rwapservices.co.uk
-- Try out our new site: http://sellmyretro.com
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm