Language C++
(hacking style)
Date: | 04/20/05 |
Author: | Tim Robinson |
URL: | n/a |
Comments: | 14 |
Info: | n/a |
Score: | ![]() |
// C++ version of 99 Bottles of beer // programmer: Tim Robinson timtroyr@ionet.net // Corrections by Johannes Tevessen #include <iostream> using namespace std; int main() { int bottles = 99; while ( bottles > 0 ) { cout << bottles << " bottle(s) of beer on the wall," << endl; cout << bottles << " bottle(s) of beer." << endl; cout << "Take one down, pass it around," << endl; cout << --bottles << " bottle(s) of beer on the wall." << endl; } return 0; }
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
object-oriented version | Tim Robinson | 04/20/05 | 4 | ![]() ![]() |
extreme template metaprogramming | Richard Wolf | 04/20/05 | 5 | ![]() ![]() |
meta programming | Arion Lei | 04/20/05 | 5 | ![]() ![]() |
Preprocessor & self-include recursion | Chocapic | 02/27/07 | 6 | ![]() ![]() |
feature creep | Jono | 04/27/09 | 1 | ![]() ![]() |
most extreme template metaprogramming | Henrik Theiling | 12/04/11 | 0 | ![]() ![]() |
7 | Jono | 04/15/09 | 0 | ![]() ![]() |
ob fuscated | Tapi (Paddy O'Brien) | 08/11/05 | 4 | ![]() ![]() |
GUI version | Martyn Davies | 05/28/05 | 1 | ![]() ![]() |
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
system ("pause"
one line before the return to make it wait for a keyboard button press.
it's easy!
#include <iostream>
#include <windows.h>
using namespace std;
int a=99;
int main()
{
cout << "Welcome to the 99 Bottles of Beer Song Program!" << endl;
cout << "Progam programmed in 2010 by Pasaria." << endl;
system("PAUSE"
while(1)
{
if( a >= 3) {
cout << a << " bottles of beer on the wall " << a << " bottles of beer." << endl;
cout << " " << endl;
a--;
Sleep(3100);
cout << "Take one down and pass it around, " << a << " bottles of beer on the wall." << endl;
}
else {
a--;
cout << "Take one down and pass it around, " << a << " bottle of beer on the wall." << endl;
cout << " " << endl;
cout << "No more bottles of beer on the wall, no more bottles of beer. " << endl;
cout << "Go to the store and buy some more, 99 bottles of beer on the wall." << endl;
system("PAUSE"
break;
}
}
}