I made this one night after reading a Slashdot posting about a programming
contest. I figured why not give it a shot. I had a lot of fun and
learning in this thing./*
Name: bottles.cpp
Author: Dennis Bottaro
Description: Generate the 99 bottles of beer song
Date: 4/28/2004
Copyright: Mine Damnit!
*/
#include <iostream.h>
// Function Headers
char* bottlecheck(int num_bottles);
void take_one_down(int howmany);
void main()
{
// Kick it 99 bottles style!
for(int bottles = 99;bottles > 0; bottles--)
{
take_one_down(bottles);
}
cout << ":-)\nWow - we need more beer!\n\n";
}
char* bottlecheck(int num_bottles)
{
if(num_bottles > 1)
{
return " bottles";
}
else
{
return " bottle";
}
}
void take_one_down(int howmany)
{
cout << howmany << bottlecheck(howmany) << " of beer on the wall.\n";
cout << howmany << bottlecheck(howmany) << " of beer!\n";
cout << "Take one down, pass it around!\n";
cout << howmany - 1 << bottlecheck(howmany - 1) << " of beer on the wall.\n\n";
}
|