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:1
Info:http://www.digitalmars.com/d/
Score: (3.76 in 34 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/051
Div Operator Editionbadmadevil02/29/080
4Philipp Winterberg04/20/056

Comments

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

gneek This looks really nice!

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: