Language C
(poor Style)
| Date: | 09/01/05 |
| Author: | Matteo Casati |
| URL: | n/a |
| Comments: | 6 |
| Info: | n/a |
| Score: |
/* The 99 Bottles of Beer Program
*
* Sept. 1st 2005
* by Matteo Casati <devaraja87^gmail^com>
*
* This is the poor-style C version of
* the program. It uses only gotos.
*/
int main()
{
int n_beers=99;
char pl='s';
goto a;
z:
return 0;
b:
n_beers--;
if(n_beers){
pl=(n_beers==1?31:'s');
printf("%d bottle%c of beer on the wall!\n",n_beers,pl);
goto a;
}else{
printf("no more bottles of beer on the wall!\n");
printf("No more bottles of beer on the wall,"
" no more bottles of beer.\nGo to the store"
" and buy some more, 99 bottles of beer on the wall!\n");
goto z;
}
a:
printf("%d bottle%c of beer on the wall, "
"%d bottle%c of beer\n",n_beers,pl,n_beers,pl);
printf("Take one down and pass it around, ");
goto b;
}
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| Linux kernel module | Stefan Scheler | 08/02/05 | 9 | |
| multithreaded version | Stefan Scheler | 05/11/05 | 5 | |
| actually produces correct lyrics :P | Dustshine | 08/20/05 | 0 | |
| standard version | Bill Wein | 04/20/05 | 2 |
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
Also:
#include <stdio.h> int main() {However, the program does use string concatenation. Perhaps poorer style might be something like
<pre>
printf("No more bottles of beer on the wall,\
no more bottles of beer.\nGo to the store\
and buy some more, 99 bottles of beer on the wall!\n"
</pre>
And I guess I now know not to put in formatting tags...
Ahh, but int main(), and not returning anything tops both