Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language D

Date:05/31/05
Author:Stewart Gordon
URL:http://www.stewartsplace.org.uk/
Comments:4
Info:http://www.digitalmars.com/d/
Score: (3.77 in 196 votes)
import std.stdio;
import std.string;

void main() {
    int bottles = 99;
    char[] text = "99 bottles";

    while (bottles != 0) {
        writefln(text, " of beer on the wall,");
        writefln(text, " of beer.");
        writefln("Take one down, pass it around,");

        if (--bottles == 1) {
            text = "1 bottle";
        } else {
            text = format("%d bottles", bottles);
        }
        writefln(text, " of beer on the wall.\n");
    }
}

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
Template metaprogrammingDon Clugston07/11/061
D feuture's galoreFredrik Olsson10/09/052
Fiber "Ring"Bryan Knowles11/17/100
Div Operator Editionbadmadevil02/29/080
5Philipp Winterberg04/20/057

Comments

>>  gneek said on 10/05/08 00:45:57

gneek This looks really nice!

>>  Sylver said on 01/30/09 07:09:35

Sylver Nice, but you are missing the last line:
"No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall."

>>  Demian said on 04/28/10 22:29:06

Demian Wow, I love this one, very creative.

>>  Chi Hair Straighteners said on 09/25/10 02:47:47

Chi Hair Straighteners Cheap Chi Flat Irons, Chi Hair Straighteners sale at Farouk outlet, 100% Authentic & Brand New, All over world free shipping.
Chi Hair Straighteners
Chi Hair Straightener
Chi Flat Irons
Chi Flat Iron
cheap gucci shoes

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!

Name:

eMail:

URL:

Security Code:
  
Comment: