|
Post by jarych on Jul 16, 2022 4:06:33 GMT
Maybe this post belongs in Code Discussion. Moderator or Administrator decide on that.
FizzBuzz as a BASIC program. This I spent maybe 30 to 40 minutes to make. Neat formatting wanted and accomplished! I put some careful thought into exactly how to handle the line which ends in a comma; and the use of INT() function.
(In case anyone not know, manage the counting number 1 to 100. fizz for multiples of 3; buzz for multiples of 5; and fizzbuzz if multiples of both 3 AND 5 ---- replace the number with the word.)
'fizbuzz select case usage? 'guessing want CR LF as chr$(13) plus chr$(10)
dim fb$(110)
for number=1 to 100 select case case number/3=int(number/3) and number/5<>int(number/5) fb$(number)="fizz" case number/3<>int(number/3) and number/5=int(number/5) fb$(number)="buzz" case number/15=int(number/15) fb$(number)="fizzbuzz" case else fb$(number)=str$(number) end select next number
for i=1 to 100 print fb$(i), if i/10=int(i/10)then print chr$(13)+chr$(10) end if next i
END
|
|
|
Post by tsh73 on Jul 16, 2022 9:20:13 GMT
Nice job two things To make a newline, you just do PRINT without anything And BASIC way to check if number is dividable to 5 is using MOD operator
if i mod 5 = 0 then
|
|
|
Post by Rod on Jul 16, 2022 15:09:32 GMT
Yeah, the other interesting thing about fizz buzz is that it is a classic “interview” test for programmers seeking jobs. It’s nice to solve it elegantly and with polished edges but if you are a programmer just get it done and coded any which way inside five minutes. That’s all the time you get.
|
|
|
Post by jarych on Jul 16, 2022 17:00:23 GMT
Nice job two things To make a newline, you just do PRINT without anything And BASIC way to check if number is dividable to 5 is using MOD operator if i mod 5 = 0 then I forget sometimes if I am in a texteditor or a mainwindow of JB. I have not gone for fizzbuzz into any graphical interface manner. I just used JB mainwindow to see if I could create a fizzbuzz example program.
|
|
|
Post by jarych on Jul 16, 2022 17:07:24 GMT
Yeah, the other interesting thing about fizz buzz is that it is a classic “interview” test for programmers seeking jobs. It’s nice to solve it elegantly and with polished edges but if you are a programmer just get it done and coded any which way inside five minutes. That’s all the time you get. Truely so or assumed! Someone might like not to look at a vertical list of numbers with certain values changed to special words; but might like instead to view those numbers arranged in rows, 1 through 10; 11 through 20; and like that, for easier viewing. Each increment of ten numbers on a new line.
|
|
|
Post by Rod on Jul 16, 2022 18:08:23 GMT
|
|
|
Post by jarych on Jul 16, 2022 19:23:58 GMT
I am now looking partway through the first article. The way the author handled multiple decision IF block was great. I felt like using SELECT CASE would be easier for me to think about how. I could have tried using an IF type block of code but I think it would have taken more time.
|
|