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

(Correct ANSI C containing no semicolons)

Date:01/15/09
Author:Steve Checkoway
URL:n/a
Comments:0
Info:n/a
Score: (3.03 in 37 votes)
#include <stdio.h>
#include <stdlib.h>

static void song( int bottles )
{
	while( (printf("%d bottles of beer on the wall, %d bottles of beer.\n"
		       "Take one down and pass it around, %d bottle%s of beer on the wall.\n\n",
		       bottles, bottles, bottles-1, bottles>2? "s":""), bottles > 2) )
		while( (--bottles,0) ) {}
	while( (puts("1 bottle of beer on the wall, 1 bottle of beer.\n"
		     "Take one down and pass it around, no more bottles of beer on the wall.\n\n"
		     "No more bottles of beer on the wall, no more bottles of beer.\n"
		     "Go to the store and buy some more, 99 bottles of beer on the wall."),0) ) {}
}

int main()
{
	while( (song(99), exit(0), 0) ) {}
}

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
Linux kernel moduleStefan Scheler08/02/0515
actually produces correct lyrics :PDustshine08/20/050
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: