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 C

(actually produces correct lyrics :P)

Date:08/20/05
Author:Dustshine
URL:n/a
Comments:0
Info:n/a
Score: (3.01 in 172 votes)
#include <stdio.h>

int main(void)
{       
        int b;
        
        for (b = 99; b >= 0; b--) {
                switch (b) {
                case 0:
                        printf("No more bottles of beer on the wall, no more bottles of beer.\n");
                        printf("Go to the store and buy some more, 99 bottles of beer on the
wall.\n");
                        break;
                case 1:
                        printf("1 bottle of beer on the wall, 1 bottle of beer.\n");
                        printf("Take one down and pass it around, no more bottles of beer on the
wall\n");
                        break;
                default:
                        printf("%d bottles of beer on the wall, %d bottles of beer.\n", b, b);      
                                  printf("Take one down and pass it around, %d %s of beer on the
wall.\n"
                                ,b - 1
                                ,((b - 1) > 1)? "bottles" : "bottle");
                        break;
                }
        }       
        
        return 0;
}

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
Linux kernel moduleStefan Scheler08/02/0515
Correct ANSI C containing no semicolonsSteve Checkoway01/15/090
multithreaded versionStefan Scheler05/11/054
poor StyleMatteo Casati09/01/056
standard versionBill Wein04/20/054

Comments

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: