Voting

Category

real language

Language C++

(hacking style)

Date:04/20/05
Author:Tim Robinson
URL:n/a
Comments:5
Info:n/a
Score: (3.26 in 27 votes)
// 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

VersionAuthorDateCommentsRate
extreme template metaprogrammingRichard Wolf04/20/055
meta programmingArion Lei04/20/052
ob fuscatedTapi (Paddy O'Brien)08/11/052
object-oriented versionTim Robinson04/20/052
GUI versionMartyn Davies05/28/050

Comments

>>  Zak said on 05/17/05 21:53:23

Zak nice, may be shorter

>>  ksdkjcjdas said on 01/10/06 11:28:23

ksdkjcjdas Well, just add in the last part and you will recreate the entire song...

>>  Mick said on 04/06/06 21:24:23

Mick I like the never ending thing.

>>  PhreakerD7 said on 04/08/06 20:44:32

PhreakerD7 Yeah. I saw the first one that was long as hell and was thinking "WHILE loop, anyone?"

>>  freacker4life said on 04/29/06 10:16:24

freacker4life Pretty Good. There's just one problem. After executing this program, it quits automatically. I think its better to add a "cin.get();" after the loop at least.

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 use the form to submit new examples!

Name:

eMail:

URL:

Security Code:
  
Comment: