Language BASIC
Date: | 05/27/05 |
Author: | M. Eric Carr |
URL: | n/a |
Comments: | 12 |
Info: | n/a |
Score: | (3.02 in 170 votes) |
10 REM Basic version of 99 bottles of beer 20 REM Modified by M. Eric Carr (eric@carrnet.net) 30 REM from prior version found on this site. 40 REM (Modified to correct "1 bottle" grammar) 50 FOR X=99 TO 1 STEP -1 60 PRINT X;"bottle"; 70 IF X<>1 THEN PRINT "s"; 80 PRINT " of beer on the wall,";X;"bottle"; 90 IF X<>1 THEN PRINT "s"; 100 PRINT " of beer" 110 PRINT "Take one down and pass it around," 120 PRINT X-1;"bottle"; 130 IF X<>1 THEN PRINT "s"; 140 PRINT " of beer on the wall" 150 NEXT
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
TRS-80 LEVEL 1 | barrym | 04/01/10 | 2 | |
trs-80 color computer | barrym | 06/10/10 | 0 | |
Atari 8Bit | barrym | 04/05/10 | 2 | |
TI99/4A EXTENDED | barrym | 06/26/10 | 0 | |
5 | Anonymous | 04/20/05 | 2 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Roland Wright said on 11/02/05 14:01:04
On some versions of BASIC (I used Microsoft BASIC on the TRS-80) the NEXT statement would have to specify the variable that is being incremented; NEXT X
Bart Barber said on 12/22/05 19:53:08
Actually, shouldn't the last decision on whether to pluralize "bottle" (line 130) be checking X-1 instead of X?
Watts Martin said on 01/10/06 08:50:25
Roland: FYI, TRS-80 BASIC didn't need the variable after the NEXT statement unless there were nested loops.
This particular code looks way too much like something I'd have written for this, too. Argh. Flashbacks.
Chris said on 07/30/06 21:15:30
Bart Barber: The variable X has already been reduced in the previous line. 130 IF X<>1 THEN PRINT "s";
M. Eric Carr said on 08/13/06 19:06:07
Yep -- that is a bug. Line 130 should read:
130 IF X<>1 THEN PRINT "s";
Sorry 'bout that. Good catch.
...and yes, it would be more universal to write
150 NEXT X
--Eric
petchema said on 11/17/06 11:01:46
Last test should be IF X-1<>1 THEN ..., or IF X<>2 THEN ...
So it doesn't factorize so easily.
Either way, that program doesn't print the reference lyrics.
Doug said on 01/02/07 16:58:22
Need the "No more bottles of beer on the wall, no more bottles of beer,
go to the store, buy some more..."
Medical-Wei said on 03/26/07 11:34:56
10 REM This is the much shorter version... The last line doesn't well...
20 FOR X=99 TO 0 STEP -1
30 ProcStr$=X;"bottles of beer"
40 IF X=1 THEN ProcStr$="1 bottle of beer"
50 IF X=0 THEN ProcStr$="No more bottles of beer"
60 IF X<>99 THEN "Take one down and pass it around,";ProcStr$;"on the wall."
70 PRINT ProcStr$;"on the wall,";ProcStr$;"."
80 NEXT X
90 PRINT "Go to the store and buy some more, 99 bottles of beer on the wall."
E said on 04/20/07 13:42:37
You assclown, this is rubbish im dissapinted in you sonny jim. Please Note:THIS IS FAKE
Cld said on 11/18/07 22:03:44
Medical-Wei:
Some BASIC doesn't support "long" variable and only supporte one char variable...
barrym said on 07/10/10 07:35:56
The decision to use strings in the first place is valid but inefficient.
For proof, see my Level 1 Basic example (Level 1 has VERY primitive string
capabilities, so in that case the decision was made for me!)
barrym said on 07/10/10 07:53:54
Sorry, M. Eric. I just realized that I was directing my comment at your commenters
instead of you. Your version simply should be revised to finish the song properly!
I (and several others) have encountered the frustration of submitting an example
with a typo or an omission, and feeling like I was going to have to see the error
posted in all of its glory forever! The web masters may someday decide to let us
perform our own revisions and view the list of candidates in the submission queue
for peer approval. Someday ... maybe?