Language B
(Ken Thompson's B, predecessor to C)
| Date: | 08/21/06 |
| Author: | Pietro Gagliardi |
| URL: | http://www.andlabs.com/ |
| Comments: | 4 |
| Info: | http://cm.bell-labs.com/cm/cs/who/dmr/kbman.html |
| Score: |
/* 99 Bottles of Beer
B Version
By Pietro Gagliardi
Started and Completed August 21, 2006
Try this if you can access a 1st edition Unix! :-) */
main()
{
auto a;
while (a >= 0) {
printf("%d %s of beer on the wall!*n", a, (a == 0 ? "bottle" : "bottles"));
printf("%d %s of beer,*n", a, (a == 0 ? "bottle" : "bottles"));
printf("You take one down, pass it around,*n");
if (a == 0) break;
printf("%d bottles of beer on the wall!*n*n", --a);
}
printf("No more bottles of beer on the wall!*n");
}
Download Source | Write Comment
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
I don't have a 1st edition Unix, nor any later 1, but...
DOES THIS WORK ?
It looks like "1 bottles" and "0 bottle" to me,
although it will "break" before it ever uses "0 bottle" !
And does "auto a" start at 99 ?
/* Is 99 snatched from within the comment ?
It would probably be better if this program would not be
completed within one day.
I found it when there were only 997 variations of
99-bottles-of-beer. Somehow Oliver Shade suddenly counted
1000 without any new additions. There must be a lot of
beer involved here...
But not in B : When the one-thousand celebrations reach
a high there is no replenishing by "going to the store" !
Nonetheless, congratulations with 1000, I like this site !
Han ten Have (Bidnija, Malta)
P.S. For a clear description of full 99-logic see the
dedicated intermediate language in my DEBUG version of 99.
It could be implemented with any Turing-complete language
although mine is not.
/* 99 Bottles of Beer
B Version
By Pietro Gagliardi
Started and Completed August 21, 2006
Try this if you can access a 1st edition Unix!
main()
{
auto a;
a = 99;
while (a >= 0) {
printf("%d %s of beer on the wall!*n", a, (a == 0 ? "bottle" : "bottles"
printf("%d %s of beer,*n", a, (a == 0 ? "bottle" : "bottles"
printf("You take one down, pass it around,*n"
if (a == 0) break;
printf("%d bottles of beer on the wall!*n*n", --a);
}
printf("No more bottles of beer on the wall!*n"
}
ugg boots sale ugg classic tall,ugg slippers,ugg boots uk
ugg boots tall,ugg boots,ugg boots uk,ugg boots sale,
ugg boots,ugg boots sale,ugg boots uk,UGG Handbags, UGG 5854 Classic Mini,UGG 1647 Tasmina,UGG 1688 Amelie Sandals,UGG 1759 Gypsy Sandal,
Ugg Women Elsey 5596,Ugg Womens Broome 5511,Ugg Tall Stripe Cable Knit 5822,UGG Womens Corinth 5756 Cocoa,Ugg Ultra Tall 5245,ugg boots,UGG Classic Tall 5815,UGG Classic Short 5825,UGG Classic Cardy 5819,UGG Bailey Button 5803,UGG Metallic Tall 5812,free shipping,sale online.!!!
Classical p90x,p90x workout,covers all the way of fitness methods.
We could enjoy best cheap cheap nike shoes sales online,about all kinds of nike air max,nike air max 90,nike shox.Run retailing and wholesale trade worldwidely for years,free shipping, super sale off retailing with 1 week delivery to your door.