99 Bottles of Beer
One program in 571 languages
 
     
  Submit new example     Change log     History     Links     Tip: internet.ls-la.net     Thanks, Oliver     Guestbook      
Choose languages starting with letter:
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
C#   C++ (Extreme template metaprogramming)   C++ (hacking style)   C++ (meta programming)   C++ (object orientated)   C     C Shell   C/C++ Preprocessor   C   Cakewalk CAL   Calc   Caml Light   Casio FX9750G   CBM Basic   CDC NOS CCL   Cecil   Centura SQL Windows   CHILL/2   Chipmunk Basic   CL for AS400   Clipper   CLIPS   CLIST   CLOS   CLU   Cobol   COCOA   Cold Fusion (cfscript)   Cold Fusion (UDF)   Cold Fusion   COMAL   Common Lisp (format string)   Common LISP   ComWic   Concurrent Clean   Cool   CorVu   Cow   CRM114   CSP   CUPL   Curl  
 
  Programming language: C#
 
/// Implementation of Ninety-Nine Bottles of Beer Song in C#.
/// What's neat is that .NET makes the Binge class a 
/// full-fledged component that may be called from any other 
/// .NET component.
///
/// Paul M. Parks
/// http://www.parkscomputing.com/
/// February 8, 2002
/// 

using System;

namespace NinetyNineBottles
{
    /// <summary>
    /// References the method of output.
    /// </summary>
    public delegate void Writer(string format, params object[] arg);

    /// <summary>
    /// References the corrective action to take when we run out.
    /// </summary>
    public delegate int MakeRun();

    /// <summary>
    /// The act of consuming all those beverages.
    /// </summary>
    public class Binge
    {
        /// <summary>
        /// What we'll be drinking.
        /// </summary>
        private string beverage;

        /// <summary>
        /// The starting count.
        /// </summary>
        private int count = 0;

        /// <summary>
        /// The manner in which the lyrics are output.
        /// </summary>
        private Writer Sing;

        /// <summary>
        /// What to do when it's all gone.
        /// </summary>
        private MakeRun RiskDUI;

        public event MakeRun OutOfBottles;


        /// <summary>
        /// Initializes the binge.
        /// </summary>
        /// <param name="count">How many we're consuming.</param>
        /// <param name="disasterWaitingToHappen">
        /// Our instructions, should we succeed.
        /// </param>
        /// <param name="writer">How our drinking song will be heard.</param>
        /// <param name="beverage">What to drink during this binge.</param>
        public Binge(string beverage, int count, Writer writer)
        {
            this.beverage = beverage;
            this.count = count;
            this.Sing = writer;
        }

        /// <summary>
        /// Let's get started.
        /// </summary>
        public void Start()
        {
            while (count > 0)
            {
                Sing(
                    @"
{0} bottle{1} of {2} on the wall,
{0} bottle{1} of {2}.
Take one down, pass it around,", 
                    count, (count == 1) ? "" : "s", beverage);

                count--;

                if (count > 0)
                {
                    Sing("{0} bottle{1} of {2} on the wall.",
                        count, (count == 1) ? "" : "s", beverage);
                }
                else
                {
                    Sing("No more bottles of {0} on the wall.", beverage);
                }

            }

            Sing(
                @"
No more bottles of {0} on the wall,
No more bottles of {0}.", beverage);

            if (this.OutOfBottles != null)
            {
                count = this.OutOfBottles();
                Sing("{0} bottles of {1} on the wall.", count, beverage);
            }
            else
            {
                Sing("First we weep, then we sleep.");
                Sing("No more bottles of {0} on the wall.", beverage);
            }
        }
    }

    /// <summary>
    /// The song remains the same.
    /// </summary>
    class SingTheSong
    {
        /// <summary>
        /// Any other number would be strange.
        /// </summary>
        const int bottleCount = 99;

        /// <summary>
        /// The entry point. Sets the parameters of the Binge and starts it.
        /// </summary>
        /// <param name="args">unused</param>
        static void Main(string[] args)
        {
            Binge binge = 
               new Binge("beer", bottleCount, new Writer(Console.WriteLine));
            binge.OutOfBottles += new MakeRun(SevenEleven);
            binge.Start();
        }

        /// <summary>
        /// There's bound to be one nearby.
        /// </summary>
        /// <returns>Whatever would fit in the trunk.</returns>
        static int SevenEleven()
        {
            Console.WriteLine("Go to the store, get some more...");
            return bottleCount;
        }
    }
}
 
  Programming language: C++ (Extreme template metaprogramming)
 
/* Richard Wolf, 2002

99 bottles of beer on the wall in an extreme template-metaprogramming style.  
It uses template specialisation to decided how to print numbers, whether 
'bottles' should be plural, and to finish the song correctly.  
Macros are used to generate the large number of specialisations required for
printing numbers nicely, eg 45 printed as "forty five" with pretty_print<45>().

Note that this will probably no compile immediately, since it requires the 
compiler to instantiate templates to a depth of (number of bottles + 4).  
Either reduce the number of starting bottles, or increase the maximum 
template depth on your compiler. 

Eg. using g++ use the -ftemplate-depth-103 command line option.

Tested on gcc, other compilers at your risk
*/

#include <iostream>

using namespace std;

template<bool small, int I>
struct pretty_printer;

#define SMALL_PRETTY_PRINTER(num, string) \
template<>\
struct pretty_printer<true, num>\
{\
    static void print()\
    {\
        cout << string;\
    }\
};

SMALL_PRETTY_PRINTER(0, "No")
SMALL_PRETTY_PRINTER(1, "One")
SMALL_PRETTY_PRINTER(2, "Two")
SMALL_PRETTY_PRINTER(3, "Three")
SMALL_PRETTY_PRINTER(4, "Four")
SMALL_PRETTY_PRINTER(5, "Five")
SMALL_PRETTY_PRINTER(6, "Six")
SMALL_PRETTY_PRINTER(7, "Seven")
SMALL_PRETTY_PRINTER(8, "Eight")
SMALL_PRETTY_PRINTER(9, "Nine")
SMALL_PRETTY_PRINTER(10, "Ten")
SMALL_PRETTY_PRINTER(11, "Eleven")
SMALL_PRETTY_PRINTER(12, "Twelve")
SMALL_PRETTY_PRINTER(13, "Thirteen")
SMALL_PRETTY_PRINTER(14, "Fourteen")
SMALL_PRETTY_PRINTER(15, "Fifteen")
SMALL_PRETTY_PRINTER(16, "Sixteen")
SMALL_PRETTY_PRINTER(17, "Seventeen")
SMALL_PRETTY_PRINTER(18, "Eighteen")
SMALL_PRETTY_PRINTER(19, "Nineteen")

#undef SMALL_PRETTY_PRINTER

template<int ones>
inline void 
print_ones();

#define ONES_PRINTER(ones, string) \
template<> \
inline void \
print_ones<ones>() \
{\
  cout << string;\
}

ONES_PRINTER(0, " ")
ONES_PRINTER(1, " one")
ONES_PRINTER(2, " two")
ONES_PRINTER(3, " three")
ONES_PRINTER(4, " four")
ONES_PRINTER(5, " five")
ONES_PRINTER(6, " six")
ONES_PRINTER(7, " seven")
ONES_PRINTER(8, " eight")
ONES_PRINTER(9, " nine")

#undef ONES_PRINTER

template<int tens>
inline void
print_tens();

#define TENS_PRINTER(tens, string) \
template<> \
inline void \
print_tens<tens>() \
{\
  cout << string;\
}

TENS_PRINTER(2, "Twenty")
TENS_PRINTER(3, "Thirty")
TENS_PRINTER(4, "Forty")
TENS_PRINTER(5, "Fifty")
TENS_PRINTER(6, "Sixty")
TENS_PRINTER(7, "Seventy")
TENS_PRINTER(8, "Eighty")
TENS_PRINTER(9, "Ninety")

#undef TENS_PRINTER

template<int I>
struct pretty_printer<false, I>
{
    static void print(){
        print_tens<(I - I%10)/10>();
        print_ones<(I%10)>();
    }
};

template<int I>
void pretty_print()
{
    pretty_printer<(I<20), I>::print();
}

template<int I>
inline void
BottlesOfBeer()
{
    pretty_print<I>();
    cout << " bottles of beer" ;
}

template<>
inline void
BottlesOfBeer<1>()
{
    pretty_print<1>();
    cout << " bottle of beer" ;
}

template<int I>
inline void
BottlesOfBeerOnTheWall()
{
    BottlesOfBeer<I>();
    cout << " on the wall";
}

template<int I>
inline void stanza()
{
    BottlesOfBeerOnTheWall<I>(); 
    cout << ",\n";
    BottlesOfBeer<I>(); 
    cout <<",\n";
}

template<int I>
inline void bridge()
{
    cout   << "Take one down, pass it around," << endl;
    BottlesOfBeerOnTheWall<I-1>();
    cout <<",\n";
}

template<>
inline void bridge<0>()
{
    cout << "Go to the store and buy some more," << endl;
    BottlesOfBeerOnTheWall<99>();
}

template<int I>
inline void verse()
{
    stanza<I>();
    bridge<I>();
}

template<int I>
inline void sing () 
{
    verse<I>();
    cout << endl;
    sing<I-1>();
} 


template<>
inline void sing<0> ()
{
    verse<0>();    
}

int main () {
  sing<99>();
}
 
  Programming language: C++ (hacking style)
 
// 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;
    }
 
  Programming language: C++ (meta programming)
 
// 99 bottles of beer, C++ template 'meta-programming' version
// By Arion Lei (philipl@cs.ust.hk)

#include <iostream.h>

template<int I>
class Loop {
public:
  static inline void f () {
    cout << I << " bottles of beer on the wall," << endl
         << I << " bottles of beer." << endl
         << "Take one down, pass it around," << endl
         << I-1 << " bottles of beer on the wall." << endl;
    Loop<I-1>::f();
  } 
};

class Loop<0> {
public:
  static inline void f () {
    cout << "Go to the store and buy some more," << endl
         << "99 bottles of beer on the wall." << endl;
  }
};


int main () {
  Loop<3>::f();
  return 0;
}
 
  Programming language: C++ (object orientated)
 
// C++ version of 99 Bottles of Beer, object oriented paradigm
// programmer: Tim Robinson timtroyr@ionet.net
#include <fstream.h>

enum Bottle { BeerBottle };

class Shelf {
    unsigned BottlesLeft;
public:
    Shelf( unsigned bottlesbought )
        : BottlesLeft( bottlesbought )
        {}
    void TakeOneDown()
        {
        if (!BottlesLeft)
            throw BeerBottle;
        BottlesLeft--;
        }
    operator int () { return BottlesLeft; }
    };

int main( int, char ** )
    {
    Shelf Beer(99);
    try {
        for (;;) {
            char *plural = (int)Beer !=1 ? "s" : "";
            cout << (int)Beer << " bottle" << plural
                 << " of beer on the wall," << endl;
            cout << (int)Beer << " bottle" << plural
                 << " of beer," << endl;
            Beer.TakeOneDown();
            cout << "Take one down, pass it around," << endl;
            plural = (int)Beer !=1 ? "s":"";
            cout << (int)Beer << " bottle" << plural
                 << " of beer on the wall." << endl;
            }
        }
    catch ( Bottle ) {
        cout << "Go to the store and buy some more," << endl;
        cout << "99 bottles of beer on the wall." << endl;
        }
    return 0;
    }
 
  Programming language: C  
 
/* C-- version of 99 Bottles of beer (Bottles.c--) */
/* See http://www.cs.utexas.edu/users/tbone/c--/   */
/* Philipp Winterberg, http://www.winterbergs.de   */

? include "WRITE.H--"
         
int b;
main ()           
{
b = 99;
do {           
    WRITEINT(b);                            
    WRITESTR(" bottle(s) of beer on the wall,\n");
    WRITEINT(b);                            
    WRITESTR(" bottle(s) of beer.\n");
    WRITESTR("Take one down, pass it around,\n");
    b--;
    WRITEINT(b);                            
    WRITESTR(" bottle(s) of beer on the wall.\n\n");
   } while (b > 0);
}
 
  Programming language: C Shell
 
#!/bin/csh

#
# C-Shell script version of 99 Bottles of Beer
#

set i = 100

while ($i > 0)

  echo -n $i " bottles of beer on the wall"
  echo $i " bottles of beer......"

   set i = `expr $i - 1`

  echo -n "take one down pass it around, " $i
  echo "bottles of beer on the wall"

end

#end of script
 
  Programming language: C/C++ Preprocessor
 
This is the pre-processor for C or C++.  Normally, not a language 
in itself, but created to make using C/C++ easier.  This is a 
novel use of the pre-processor

-- BEER.CPP ---------------------------------------------------------
// 99 Bottles written entirely in Visual C++ preprocessor directives.
// By Wim Rijnders.
#pragma warning(disable : 4005 )

#define BOTTLES "bottles"
#define TAKE_ONE_DOWN "Take one down, pass it around,"
#define DEC_NUM 9
#define DEC_STR "9"
#define DEC2_NUM 9
#define DEC2_STR "9"

#define TEST_BOTTLES(a,b) (DEC2_NUM == a  && DEC_NUM == b )
#define STILL_HAVE__BOTTLES !TEST_BOTTLES(0,0)
#define NO_MORE__BOTTLES TEST_BOTTLES(0,0)
#define JUST_ONE__BOTTLE TEST_BOTTLES(0,1)

#define OF_BEER DEC2_STR DEC_STR " " BOTTLES " of beer"
#define BEER_ON_WALL OF_BEER " on the wall"

#include "sing.h"
-- SING.H -----------------------------------------------------------
//Following to beat the 32-file include limit of VC
#if STILL_HAVE__BOTTLES
	#include "stanza.h"               
	#include "stanza.h"               
	#include "stanza.h"               
	#include "stanza.h"               
	#include "sing.h"               
#endif 
-- STANZA.H ---------------------------------------------------------
#if STILL_HAVE__BOTTLES
	#pragma message(BEER_ON_WALL ",")
	#pragma message(OF_BEER ",")
	#pragma message(TAKE_ONE_DOWN)
	
	#include "dec.h"         
	#if NO_MORE__BOTTLES
		#define DEC2_STR ""
		#define DEC_STR "No more"
	#endif	
	
	#if JUST_ONE__BOTTLE
		#define BOTTLES "bottle"
	#else
		#define BOTTLES "bottles"	
	#endif
	
	#pragma message(BEER_ON_WALL ".")
	#pragma message("")
#endif 
-- DEC.H ------------------------------------------------------------
#if DEC_NUM == 9
	#define DEC_NUM 8
	#define DEC_STR "8"
#elif DEC_NUM == 8
	#define DEC_NUM 7
	#define DEC_STR "7"
#elif DEC_NUM == 7
	#define DEC_NUM 6
	#define DEC_STR "6"
#elif DEC_NUM == 6
	#define DEC_NUM 5
	#define DEC_STR "5"
#elif DEC_NUM == 5
	#define DEC_NUM 4
	#define DEC_STR "4"
#elif DEC_NUM == 4
	#define DEC_NUM 3
	#define DEC_STR "3"
#elif DEC_NUM == 3
	#define DEC_NUM 2
	#define DEC_STR "2"
#elif DEC_NUM == 2
	#define DEC_NUM 1
	#define DEC_STR "1"
#elif DEC_NUM == 1
	#define DEC_NUM 0
	#define DEC_STR "0"
#elif DEC_NUM == 0    
	#include "dec2.h"
	#define DEC_NUM 9
	#define DEC_STR "9"
#endif   
-- DEC2.H -----------------------------------------------------------
#if DEC2_NUM == 9
	#define DEC2_NUM 8
	#define DEC2_STR "8"
#elif DEC2_NUM == 8
	#define DEC2_NUM 7
	#define DEC2_STR "7"
#elif DEC2_NUM == 7
	#define DEC2_NUM 6
	#define DEC2_STR "6"
#elif DEC2_NUM == 6
	#define DEC2_NUM 5
	#define DEC2_STR "5"
#elif DEC2_NUM == 5
	#define DEC2_NUM 4
	#define DEC2_STR "4"
#elif DEC2_NUM == 4
	#define DEC2_NUM 3
	#define DEC2_STR "3"
#elif DEC2_NUM == 3
	#define DEC2_NUM 2
	#define DEC2_STR "2"
#elif DEC2_NUM == 2
	#define DEC2_NUM 1
	#define DEC2_STR "1"
#elif DEC2_NUM == 1
	#define DEC2_NUM 0
	#define DEC2_STR ""
#endif                    
 
  Programming language: C
 
/*
 * 99 bottles of beer in ansi c
 *
 * by Bill Wein: bearheart@bearnet.com
 *
 */

#define MAXBEER (99)

void chug(int beers);

main()
{
register beers;

for(beers = MAXBEER; beers; chug(beers--))
  puts("");

puts("\nTime to buy more beer!\n");

exit(0);
}

void chug(register beers)
{
char howmany[8], *s;

s = beers != 1 ? "s" : "";
printf("%d bottle%s of beer on the wall,\n", beers, s);
printf("%d bottle%s of beeeeer . . . ,\n", beers, s);
printf("Take one down, pass it around,\n");

if(--beers) sprintf(howmany, "%d", beers); else strcpy(howmany, "No more");
s = beers != 1 ? "s" : "";
printf("%s bottle%s of beer on the wall.\n", howmany, s);
}
 
  Programming language: Cakewalk CAL
 
Cakewalk Application Language (v3). Cakewalk is a MIDI sequencing 
program which can manipulate midi data using CAL programs.  This 
program is multi-file and file name breaks are in italics.

<i>-- BEER.CAL --</i>
;  BEER.CAL by Tom Murphy 7 <poop@cmu.edu> for Cakewalk CAL 
; (version 3)
; It will even play the song along if you have a MIDI device 
; hooked up, otherwise it is REALLY boring.
;  <9.9.97>

(do
	(int beer 99)
	(while (!= beer 0) (do
	(if (!= beer 1)
       (message beer "bottles of beer on the wall")
       (message "1 more bottle of beer on the wall...")
	)
	(include "part1.cal")
	(if (!= beer 1)
       (message beer "bottles of beer")
       (message "1 more bottle of beer...")
	)
		 (delay 600)
      (include "part2.cal")
   (message "Take one down, pass it around")
   (delay 600) (include "part3.cal")
		(-- beer)
	(delay 600)
	(if (!= beer 1)
       (message beer "bottles of beer on the wall")
       (message "1 more bottle of beer on the wall...")
	)
    (include "part4.cal") (delay 600)
		))
   (pause "We're out of beer, dude.")
)


<i>-- PART1.CAL --</i>
; PART1.CAL
; replace this (and the other PART?.CAL files) with:
; (do
;    NIL
; )
; if you want it to not make sounds.

(do
  (sendMIDI -1 1 NOTE 48 64)
      (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0)
   (sendMIDI -1 1 NOTE 48 0) (delay 100) (sendMIDI -1 1 NOTE 43 64)
      (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 55 64) (delay 300) (sendMIDI -1 1 NOTE 55 0)
  (sendMIDI -1 1 NOTE 43 0) (delay 100) (sendMIDI -1 1 NOTE 48 64)
      (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 60 64) (delay 300) (sendMIDI -1 1 NOTE 60 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 60 64) (delay 600) (sendMIDI -1 1 NOTE 60 0)
   (sendMIDI -1 1 NOTE 48 0)
)

<i>-- PART2.CAL --</i>
(do
  (sendMIDI -1 1 NOTE 50 64)
      (sendMIDI -1 1 NOTE 62 64) (delay 300) (sendMIDI -1 1 NOTE 62 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 62 64) (delay 300) (sendMIDI -1 1 NOTE 62 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 62 64) (delay 300) (sendMIDI -1 1 NOTE 62 0)
   (sendMIDI -1 1 NOTE 50 0) (delay 100) (sendMIDI -1 1 NOTE 45 64)
      (sendMIDI -1 1 NOTE 57 64) (delay 300) (sendMIDI -1 1 NOTE 57 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 57 64) (delay 300) (sendMIDI -1 1 NOTE 57 0)
    (delay 100)
      (sendMIDI -1 1 NOTE 57 64) (delay 300) (sendMIDI -1 1 NOTE 57 0)
  (sendMIDI -1 1 NOTE 45 0) (delay 100) (sendMIDI -1 1 NOTE 50 64)
      (sendMIDI -1 1 NOTE 62 64) (delay 1200) (sendMIDI -1 1 NOTE 62 0)
   (sendMIDI -1 1 NOTE 50 0)
)

<i>-- PART3.CAL --</i>
(do
   (sendMIDI -1 1 NOTE 43 64)
   (sendMIDI -1 1 NOTE 59 64) (delay 400) (sendMIDI -1 1 NOTE 59 0)
   (delay 300) (sendMIDI -1 1 NOTE 59 64) (delay 300)
   (sendMIDI -1 1 NOTE 59 0) (delay 100) (sendMIDI -1 1 NOTE 59 64)
   (delay 600) (sendMIDI -1 1 NOTE 59 0) (delay 400)
   (sendMIDI -1 1 NOTE 59 64) (delay 250) (sendMIDI -1 1 NOTE 59 0)
   (delay 100) (sendMIDI -1 1 NOTE 59 64) (delay 250)
   (sendMIDI -1 1 NOTE 59 0) (delay 100) (sendMIDI -1 1 NOTE 59 64)
   (delay 250) (sendMIDI -1 1 NOTE 59 0) (delay 100)
   (sendMIDI -1 1 NOTE 59 64) (delay 500) (sendMIDI -1 1 NOTE 59 0)
   (sendMIDI -1 1 NOTE 43 0)
)

<i>-- PART4.CAL --</i>
<PRE>
(do
   (sendMIDI -1 1 NOTE 43 64)
   (sendMIDI -1 1 NOTE 55 64) (delay 400) (sendMIDI -1 1 NOTE 55 0)
   (delay 300) (sendMIDI -1 1 NOTE 55 64) (delay 300)
   (sendMIDI -1 1 NOTE 55 0) (delay 100) (sendMIDI -1 1 NOTE 57 64)
   (delay 600) (sendMIDI -1 1 NOTE 57 0) (delay 100)
   (sendMIDI -1 1 NOTE 59 64) (delay 250) (sendMIDI -1 1 NOTE 59 0)
   (sendMIDI -1 1 NOTE 43 0) (delay 100) (sendMIDI -1 1 NOTE 36 64)
   (sendMIDI -1 1 NOTE 60 64) (delay 250) (sendMIDI -1 1 NOTE 60 0)
   (delay 100) (sendMIDI -1 1 NOTE 60 64) (delay 250)
   (sendMIDI -1 1 NOTE 60 0) (delay 100) (sendMIDI -1 1 NOTE 60 64)
   (delay 250) (sendMIDI -1 1 NOTE 60 0) (delay 100)
   (sendMIDI -1 1 NOTE 60 64) (delay 500) (sendMIDI -1 1 NOTE 60 0)
   (sendMIDI -1 1 NOTE 36 0)
)
 
  Programming language: Calc
 
/*
 * 99 bottles of beer
 *
 * See:
 *      http://reality.sgi.com/csp/ioccc/noll/noll.html#calc
 */

for (i=99; i > 0;) {
    /* current wall state */
    some_bottles = (i != 1) ? "bottles" : "bottle";
    print i, some_bottles, "of beer on the wall,",;
    print i, some_bottles, "of beer!";

    /* glug, glug */
    --i;
    print "Take one down and pass it around,",;

    /* new wall state */
    less = (i > 0) ? i : "no";
    bottles = (i!=1) ? "bottles" : "bottle";
    print less, bottles, "of beer on the wall!\n";
}
 
  Programming language: Caml Light
 
(* Caml Light version of 99 bottles of beer *)
(* Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu) *)
let rec bottles =
  function 1 -> print_string "1 bottle of beer on the wall, 1 bottle of beer\n";
                print_string "Take one down, pass it around,\n";
                print_string "no more bottles of beer on the wall\n"
         | n -> print_int n;
                print_string " bottles of beer on the wall, ";
                print_int n;
                print_string " bottles of beer\n";
                print_string "Take one down and pass it around,\n";
                print_int (n-1);
                print_string " bottles of beer on the wall\n";
                bottles (n-1)
in
   bottles 99;;
 
  Programming language: Casio FX9750G
 
The "Do" loops are only there to make it look a bit nicer - otherwise it just
shoots through too fast to read. Feel free to remove them.All lines must be
ended with the Enter character (EXE) It may work on some other Casio models 
as well.

For 99 -> K To 2 Step -1
Locate 1,1,K
Locate 4,1,"BOTTLES OF BEER ON"
Locate 4,2,"THE WALL"
50->X
Do
X - 1 ->X
LpWhile X =/=0
Locate 1,3,K
Locate 4,3,"BOTTLES OF BEER"
50->X
Do
X - 1 ->X
LpWhile X =/= 0
Locate 1,4,"YOU TAKE ONE DOWN"
20->X
Do
X - 1 ->X
LpWhile X =/= 0
Locate 1,5,"AND PASS IT AROUND"
20->X
Do
X - 1 ->X
LpWhile X =/= 0
Locate 1,6,K-1
If K > 1 Then Locate 4,6,"BOTTLES OF BEER ON"
Else Locate 4,6,"BOTTLE OF BEER ON"
Locate 4,7,"THE WALL"
ClrText
Next
"1  BOTTLE OF BEER ON"
"   THE WALL"
50->X
Do
X - 1 ->X
LpWhile X =/=0
"1  BOTTLE OF BEER"
50->X
Do
X - 1 ->X
LpWhile X =/=0
"YOU TAKE IT DOWN"
20->X
Do
X - 1 ->X
LpWhile X =/=0
"AND PASS IT AROUND"
20->X
Do
X - 1 ->X
LpWhile X =/=0
"NO MORE BOTTLES OF
"BEER ON THE WALL"
 
  Programming language: CBM Basic
 
0 REM PAYTON BYRD - 2002
1 ?CHR$(147): FOR I=99 TO 0 STEP -1
2 ?I;" BOTTLES OF BEER ON THE WALL,"
3 ?I;" BOTTLES OF BEER!"
4 ?I;" TAKE ONE DOWN, PASS IT AROUND,"
5 ?I-1;" BOTTLES OF BEER ON THE WALL!":?""
6 NEXT I
7 REM THIS SAMPLE WILL WORK ON VIC-20,
8 REM C=16/PLUS 4, C=64, AND C=128
 
  Programming language: CDC NOS CCL
 
Contributed by Valerie Harris (valerie@grin.net) with a little help from my friends
CDC = Control Data Corporation
NOS = Network Operating System
CCL = Cyber Control Language
It's the operating system control language of the cyber machine.

.PROC,DRV99*I,
COUNT = (*N=10,*F).
.HELP.
THIS PROC READS ARGUMENT COUNT, AND INITIALIZES
REGISTER COUNTER TO THAT VALUE.
THEN THIS PROC LOOPS FOR THAT MANY COUNTS, DECREMENTING
THE REGISTER COUNTER EVERY LOOP.  DURING THE LOOP THIS PROC
CALLS PRN99 WHICH PRINTS MESSAGE FOR THAT COUNT
.HELP,COUNT.
THIS IS THE INITITAL COUNT, THE COUNT FROM WHICH TO DECREMENT.
.ENDHELP
.IF,NUM(COUNT),QUIT.
SET,R1=COUNT.
SET,R2=0.
WHILE,R1.GT.R2,LOOP.
BEGIN,PRN99,DRV99,R1.
SET,R1=R1-1.
ENDW,LOOP.
NOTE./NO BOTTLES OF BEER ON THE WALL
REVERT,NOLIST.
.ENDIF,QUIT.
REVERT,ABORT.  NONNUMERIC PASSES
.PROC,PRN99*I,COUNT=(*N=10,*F).
.SET,K9=STRD(COUNT).
NOTE./K9 BOTTLES OF BEER ON THE WALL
NOTE./K9 BOTTLES OF BEER
NOTE./TAKE ONE DOWN, AND PASS IT AROUND/
REVERT,NOLIST.
 
  Programming language: Cecil
 
-- 99 Bottles of Beer in Cecil
-- by David Eddyshaw, david@jeddyshaw.freeserve.co.uk
-- See http://www.cs.washington.edu/research/projects/cecil/www/cecil-home.html

method bob(n@int) {
    if(n == 0, { "No more bottles".print },
  { if(n == 1, { "1 bottle".print },
               {  n.print; " bottles".print })})
}

do (99, &(i) {
  bob(99-i); " of beer on the wall,".print_line;
  bob(99-i); " of beer;".print_line;
  "Take one down and pass it around:".print_line;
  bob(98-i); " of beer on the wall.\n".print_line;
});
 
  Programming language: Centura SQL Windows
 
SQLWindows is a RAD environment for Windows that is largely concerned 
with creating front ends for processes that are based around a DBMS. 
There's really very little code here; for a program of this size, the 
housekeeping stuff is overwhelming.


.head 0 +  Application Description: 99 Bottles of Beer, by Gregory Weston
.head 1 -  Outline Version - 4.0.26
.head 1 +  Design-time Settings
.data VIEWINFO
0000: 6F00000001000000 FFFF01000D004347 5458566965775374 6174650400010000
0020: 0000000000A50000 002C000000020000 0003000000FFFFFF FFFFFFFFFFFCFFFF
0040: FFE9FFFFFFFFFFFF FF000000007C0200 004D010000010000 0000000000010000
0060: 000F4170706C6963 6174696F6E497465 6D04000000075769 6E646F77730A4265
0080: 657257696E646F77 0946756E6374696F 6E7306446F536F6E 67
.enddata
.data DT_MAKERUNDLG
0000: 00000000000E433A 5C626F74746C6573 2E6578650D433A5C 6E65776170702E64
0020: 6C6C0D433A5C6E65 776170702E617063 000001010115433A 5C43656E74757261
0040: 5C6E65776170702E 72756E15433A5C43 656E747572615C6E 65776170702E646C
0060: 6C15433A5C43656E 747572615C6E6577 6170702E61706300 0001010115433A5C
0080: 43656E747572615C 6E65776170702E61 706415433A5C4365 6E747572615C6E65
00A0: 776170702E646C6C 15433A5C43656E74 7572615C6E657761 70702E6170630000
00C0: 01010115433A5C43 656E747572615C6E 65776170702E6170 6C15433A5C43656E
00E0: 747572615C6E6577 6170702E646C6C15 433A5C43656E7475 72615C6E65776170
0100: 702E617063000001 0101
.enddata
.head 2 -  Outline Window State: Normal
.head 2 +  Outline Window Location and Size
.data VIEWINFO
0000: 6600040003002D00 0000000000000000 0000B71E5D0E0500 1D00FFFF4D61696E
0020: 0000000000000000 0000000000000000 0000003B00010000 00000000000000E9
0040: 1E800A00008600FF FF496E7465726E61 6C2046756E637469 6F6E730000000000
0060: 0000000000000000 0000000000003200 0100000000000000 0000E91E800A0000
0080: DF00FFFF56617269 61626C6573000000 0000000000000000 0000000000000000
00A0: 3000010000000000 00000000F51E100D 0000F400FFFF436C 6173736573000000
00C0: 0000000000000000 0000000000000000
.enddata
.data VIEWSIZE
0000: D000
.enddata
.head 3 -  Left:   -0.013"
.head 3 -  Top:    0.0"
.head 3 -  Width:  8.013"
.head 3 -  Height: 4.969"
.head 2 +  Options Box Location
.data VIEWINFO
0000: D4180909B80B1A00
.enddata
.data VIEWSIZE
0000: 0800
.enddata
.head 3 -  Visible? Yes
.head 3 -  Left:   4.15"
.head 3 -  Top:    1.885"
.head 3 -  Width:  3.8"
.head 3 -  Height: 2.073"
.head 2 +  Class Editor Location
.head 3 -  Visible? No
.head 3 -  Left:   0.575"
.head 3 -  Top:    0.094"
.head 3 -  Width:  5.063"
.head 3 -  Height: 2.719"
.head 2 +  Tool Palette Location
.head 3 -  Visible? No
.head 3 -  Left:   6.388"
.head 3 -  Top:    0.729"
.head 2 -  Fully Qualified External References? Yes
.head 2 -  Reject Multiple Window Instances? No
.head 2 -  Enable Runtime Checks Of External References? Yes
.head 2 -  Use Release 4.0 Scope Rules? No
.head 1 -  Libraries
.head 1 +  Global Declarations
.head 2 +  Window Defaults
.head 3 +  Tool Bar
.head 4 -  Display Style? Etched
.head 4 -  Font Name: MS Sans Serif
.head 4 -  Font Size: 8
.head 4 -  Font Enhancement: System Default
.head 4 -  Text Color: System Default
.head 4 -  Background Color: System Default
.head 3 +  Form Window
.head 4 -  Display Style? Etched
.head 4 -  Font Name: MS Sans Serif
.head 4 -  Font Size: 8
.head 4 -  Font Enhancement: System Default
.head 4 -  Text Color: System Default
.head 4 -  Background Color: System Default
.head 3 +  Dialog Box
.head 4 -  Display Style? Etched
.head 4 -  Font Name: MS Sans Serif
.head 4 -  Font Size: 8
.head 4 -  Font Enhancement: System Default
.head 4 -  Text Color: System Default
.head 4 -  Background Color: System Default
.head 3 +  Top Level Table Window
.head 4 -  Font Name: MS Sans Serif
.head 4 -  Font Size: 8
.head 4 -  Font Enhancement: System Default
.head 4 -  Text Color: System Default
.head 4 -  Background Color: System Default
.head 3 +  Data Field
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Multiline Field
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Spin Field
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Background Text
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Pushbutton
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 3 +  Radio Button
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Check Box
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Option Button
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 3 +  Group Box
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Child Table Window
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  List Box
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Combo Box
.head 4 -  Font Name: Use Parent
.head 4 -  Font Size: Use Parent
.head 4 -  Font Enhancement: Use Parent
.head 4 -  Text Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 3 +  Line
.head 4 -  Line Color: Use Parent
.head 3 +  Frame
.head 4 -  Border Color: Use Parent
.head 4 -  Background Color: 3D Face Color
.head 3 +  Picture
.head 4 -  Border Color: Use Parent
.head 4 -  Background Color: Use Parent
.head 2 +  Formats
.head 3 -  Number: 0'%'
.head 3 -  Number: #0
.head 3 -  Number: ###000
.head 3 -  Number: ###000;'($'###000')'
.head 3 -  Date/Time: hh:mm:ss AMPM
.head 3 -  Date/Time: M/d/yy
.head 3 -  Date/Time: MM-dd-yy
.head 3 -  Date/Time: dd-MMM-yyyy
.head 3 -  Date/Time: MMM d, yyyy
.head 3 -  Date/Time: MMM d, yyyy hh:mm AMPM
.head 3 -  Date/Time: MMMM d, yyyy hh:mm AMPM
.head 2 -  External Functions
.head 2 +  Constants
.data CCDATA
0000: 3000000000000000 0000000000000000 00000000
.enddata
.data CCSIZE
0000: 1400
.enddata
.head 3 -  System
.head 3 -  User
.head 2 -  Resources
.head 2 -  Variables
.head 2 -  Internal Functions
.head 2 -  Named Menus
.head 2 -  Class Definitions
.head 2 +  Default Classes
.head 3 -  MDI Window: cBaseMDI
.head 3 -  Form Window:
.head 3 -  Dialog Box:
.head 3 -  Table Window:
.head 3 -  Quest Window:
.head 3 -  Data Field:
.head 3 -  Spin Field:
.head 3 -  Multiline Field:
.head 3 -  Pushbutton:
.head 3 -  Radio Button:
.head 3 -  Option Button:
.head 3 -  Check Box:
.head 3 -  Child Table:
.head 3 -  Quest Child Window: cQuickDatabase
.head 3 -  List Box:
.head 3 -  Combo Box:
.head 3 -  Picture:
.head 3 -  Vertical Scroll Bar:
.head 3 -  Horizontal Scroll Bar:
.head 3 -  Column:
.head 3 -  Background Text:
.head 3 -  Group Box:
.head 3 -  Line:
.head 3 -  Frame:
.head 3 -  Custom Control:
.head 2 -  Application Actions
.head 1 +  Form Window: BeerWindow
.head 2 -  Class:
.head 2 -  Property Template:
.head 2 -  Class DLL Name:
.head 2 -  Title: Bottles
.head 2 -  Icon File:
.head 2 -  Accesories Enabled? No
.head 2 -  Visible? Yes
.head 2 -  Display Settings
.head 3 -  Display Style? Default
.head 3 -  Visible at Design time? Yes
.head 3 -  Automatically Created at Runtime? Yes
.head 3 -  Initial State: Normal
.head 3 -  Maximizable? Yes
.head 3 -  Minimizable? Yes
.head 3 -  System Menu? Yes
.head 3 -  Resizable? No
.head 3 -  Window Location and Size
.head 4 -  Left:   Default
.head 4 -  Top:    Default
.head 4 -  Width:  10.583"
.head 4 -  Width Editable? Yes
.head 4 -  Height: 4.405"
.head 4 -  Height Editable? Yes
.head 3 -  Form Size
.head 4 -  Width:  Default
.head 4 -  Height: Default
.head 4 -  Number of Pages: Dynamic
.head 3 -  Font Name: Default
.head 3 -  Font Size: Default
.head 3 -  Font Enhancement: Default
.head 3 -  Text Color: Default
.head 3 -  Background Color: Default
.head 2 -  Description:
.head 2 -  Named Menus
.head 2 -  Menu
.head 2 +  Tool Bar
.head 3 -  Display Settings
.head 4 -  Display Style? Default
.head 4 -  Location? Top
.head 4 -  Visible? Yes
.head 4 -  Size: Default
.head 4 -  Size Editable? Yes
.head 4 -  Font Name: Default
.head 4 -  Font Size: Default
.head 4 -  Font Enhancement: Default
.head 4 -  Text Color: Default
.head 4 -  Background Color: Default
.head 3 -  Contents
.head 2 +  Contents
.head 3 +  Pushbutton: pb1
.head 4 -  Class Child Ref Key: 0
.head 4 -  Class ChildKey: 0
.head 4 -  Class:
.head 4 -  Property Template:
.head 4 -  Class DLL Name:
.head 4 -  Title: Sing!
.head 4 -  Window Location and Size
.head 5 -  Left:   0.183"
.head 5 -  Top:    0.155"
.head 5 -  Width:  1.2"
.head 5 -  Width Editable? Yes
.head 5 -  Height: 0.298"
.head 5 -  Height Editable? Yes
.head 4 -  Visible? Yes
.head 4 -  Keyboard Accelerator: (none)
.head 4 -  Font Name: Default
.head 4 -  Font Size: Default
.head 4 -  Font Enhancement: Default
.head 4 -  Picture File Name:
.head 4 -  Picture Transparent Color: None
.head 4 -  Image Style: Single
.head 4 -  Text Color: Default
.head 4 -  Background Color: Default
.head 4 +  Message Actions
.head 5 +  On SAM_Click
.head 6 -  Call DoSong() 
.head 3 +  Multiline Field: ml1
.head 4 -  Class Child Ref Key: 0
.head 4 -  Class ChildKey: 0
.head 4 -  Class:
.head 4 -  Property Template:
.head 4 -  Class DLL Name:
.head 4 -  Data
.head 5 -  Maximum Data Length: Default
.head 5 -  String Type: String
.head 5 -  Editable? Yes
.head 4 -  Display Settings
.head 5 -  Border? Yes
.head 5 -  Word Wrap? No
.head 5 -  Vertical Scroll? Yes
.head 5 -  Window Location and Size
.head 6 -  Left:   1.583"
.head 6 -  Top:    0.155"
.head 6 -  Width:  8.1"
.head 6 -  Width Editable? Yes
.head 6 -  Height: 3.417"
.head 6 -  Height Editable? Yes
.head 5 -  Visible? Yes
.head 5 -  Font Name: Default
.head 5 -  Font Size: Default
.head 5 -  Font Enhancement: Default
.head 5 -  Text Color: Default
.head 5 -  Background Color: Default
.head 4 -  Message Actions
.head 2 +  Functions
.head 3 +  Function: DoSong
.head 4 -  Description:
.head 4 -  Returns
.head 4 -  Parameters
.head 4 -  Static Variables
.head 4 +  Local variables
.head 5 -  Number: theBottleCount
.head 5 -  String: theCountString
.head 5 -  String: thePlural
.head 5 -  String: theNewLine
.head 4 +  Actions
.head 5 -  Set theNewLine = SalNumberToChar(13) || SalNumberToChar(10)
.head 5 -  Set theBottleCount = 99
.head 5 -  Call SalClearField(ml1)
.head 5 -  Call SalSetMaxDataLength(ml1, 32767)
.head 5 +  Loop
.head 6 -  Set theCountString = CountString(theBottleCount)
.head 6 -  Set thePlural = PluralString(theBottleCount)
.head 6 -  Set ml1 = ml1 || theCountString || " bottle" || thePlural || 
" of beer on the wall; " || theCountString || " bottle" || thePlural || 
" of beer." || theNewLine || "Take one down, pass it around: " || 
CountString(theBottleCount - 1) || " bottle" || 
PluralString(theBottleCount - 1) || " of beer on the wall." || theNewLine
.head 6 -  Set theBottleCount = theBottleCount - 1
.head 6 +  If theBottleCount = 0
.head 7 -  Break
.head 3 +  Function: CountString
.head 4 -  Description:
.head 4 +  Returns
.head 5 -  String:
.head 4 +  Parameters
.head 5 -  Number: inCount
.head 4 -  Static Variables
.head 4 -  Local variables
.head 4 +  Actions
.head 5 +  If inCount = 0
.head 6 -  Return "No"
.head 5 +  Else
.head 6 -  Return SalNumberToStrX(inCount, 0)
.head 3 +  Function: PluralString
.head 4 -  Description:
.head 4 +  Returns
.head 5 -  String:
.head 4 +  Parameters
.head 5 -  Number: inCount
.head 4 -  Static Variables
.head 4 -  Local variables
.head 4 +  Actions
.head 5 +  If inCount = 1
.head 6 -  Return ""
.head 5 +  Else
.head 6 -  Return "s"
.head 2 -  Window Parameters
.head 2 -  Window Variables
.head 2 -  Message Actions
 
  Programming language: CHILL/2
 
io: MODULE
/*
  The CHILL/2 compiler I use has no VARYING strings.
  To tackle this inconvenience, I declare a record with variants..
*/

  GRANT String, nul, OutS, OutL, OutC, OutI;

  NEWMODE String = STRUCT(CASE OF
    :s9  CHAR(9),
    :s11 CHAR(11),
    :s13 CHAR(13),
    :s16 CHAR(16),
    :s31 CHAR(31)
    ESAC
  );

  SYN nul = C'00';

  OutS: PROC(s String LOC); END OutS;
  OutL: PROC(); END OutL;
  OutC: PROC(c CHAR); END OutC;
  OutI: PROC(i INT); END OutI;

END io;

beer: MODULE /* jr_31jan97 */

  SEIZE String, nul, OutC, OutS, OutI, OutL <> USING io;

  bottles: PROC(n INT, wall BOOL, end CHAR);
    DCL s String;
    IF n>1 THEN OutI(n); s.s9:=' Bottles'//nul;
    ELSIF n=1 THEN s.s11:='one Bottle'//nul;
    ELSIF n=0 THEN s.s16:='no more Bottles'//nul;
    FI;
    OutS(s); s.s9:=' of Beer'//nul; OutS(s);
    IF wall THEN s.s13:=' on the Wall'//nul; OutS(s); FI;
    OutC(end); OutL();
  END bottles;

  singTheSong: PROC();
    DCL i INT, s String;
    DO FOR i:=99 DOWN TO 1;
      bottles(i, TRUE, ',');
      bottles(i, FALSE, '.');
      s.s31:='Take one down, pass it around,'//nul; OutS(s); OutL();
      bottles(i-1, TRUE, '.');
    OD;
  END singTheSong;

END beer;
 
  Programming language: Chipmunk Basic
 
# Chipmunk Basic version of 99 Bottles of beer (Bottles.bas)
# See http://www.rahul.net/rhn/cbas.page.html
# Philipp Winterberg, http://www.winterbergs.de
1     
2 FOR b=99 TO 1 STEP -1
3  ? b;" bottle(s) of beer on the wall,"
4  ? b;" bottle(s) of beer."
5  ? "Take one down, pass it around,"
6  ? b-1;" bottle(s) of beer on the wall." : ? " "
7 NEXT
 
  Programming language: CL for AS400
 
    PGM
    /*  99 Bottles of Beer in AS/400 CL (Command Language)           */
    /*  Programmer:  Werner Grzemba, 101326.3300@compuserve.com      */

    /*  To avoid the necessity of any user action, the output is     */
    /*  sent to the status line (except of the buy-request at end)   */

             DCL        VAR(&MSG) TYPE(*CHAR) LEN(79)
             DCL        VAR(&BEER1) TYPE(*CHAR) LEN(30) VALUE(' +
                          bottles of beer on the wall, ')
             DCL        VAR(&BEER2) TYPE(*CHAR) LEN(31) VALUE('Take +
                          one down, pass it around, ')
             DCL        VAR(&BEER3) TYPE(*CHAR) LEN(78) VALUE('Go +
                          to the store and by some more... 99 +
                          bottles of beer')
             DCL        VAR(&BOTTLES) TYPE(*DEC) LEN(2 0) VALUE(99)
             DCL        VAR(&XB) TYPE(*CHAR) LEN(2)
             DCL        VAR(&RPY) TYPE(*CHAR) LEN(4)

             CHGVAR     VAR(&XB) VALUE(&BOTTLES)

    MOREBEER:
             CHGVAR     VAR(&MSG) VALUE(&XB *CAT &BEER1 *CAT &XB +
                          *CAT %SST(&BEER1 1 16))
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) +
                          TOPGMQ(*EXT) MSGTYPE(*STATUS)
             DLYJOB     DLY(1)
             CHGVAR     VAR(&BOTTLES) VALUE(&BOTTLES - 1)
             CHGVAR     VAR(&XB) VALUE(&BOTTLES)
             CHGVAR     VAR(&MSG) VALUE(&BEER2 *CAT &XB *CAT +
                          %SST(&BEER1 1 28))
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) +
                          TOPGMQ(*EXT) MSGTYPE(*STATUS)
             DLYJOB     DLY(1)
             IF         COND(&BOTTLES > 0) THEN(GOTO CMDLBL(MOREBEER))

             CHGVAR     VAR(&MSG) VALUE('No more' *CAT &BEER1 *CAT +
                          'no more' *CAT %SST(&BEER1 1 16))
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) +
                          TOPGMQ(*EXT) MSGTYPE(*STATUS)
             DLYJOB     DLY(2)
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&BEER3) +
                          TOPGMQ(*EXT) MSGTYPE(*INQ) KEYVAR(&RPY)

    ENDPGM
 
  Programming language: Clipper
 
/* Tim Nason, 27 Oct 95 */

procedure beer
local nBeers := 99
    while .t.
        ?
        ? alltrim( str( nBeers ) ) + ' bottle' + iif( nBeers = 1, '', 's' ) + ;
             ' of beer on the wall.'
        ? alltrim( str( nBeers ) ) + ' bottle' + iif( nBeers-- = 1, '', 's' ) + ;
                ' of beer.'
        if nBeers < 0
            ? "Go to the store and buy some more."
            nBeers := 99
            ? '99 bottles of beer on the wall.'
        else        
            ? 'Take one down, pass it around,'
            ? alltrim( str( nBeers ) ) + ' bottles of beer on the wall.'
        endif
    enddo
return
 
  Programming language: CLIPS
 
;Written by Bill Ensinger (Bill222E@aol.com) on Saturday February 24, 1996
;8:00 - 9:41 pm Eastern Standard time at Taylor University.
;All praise to God; note that we just pass the beer, but don't drink!

(deftemplate beer
  (field ninetynine))

(deffacts bottles
  (beer (ninetynine 99)))


(defrule Bottlesninetynine ""
  (beer (ninetynine ?bottlenum))
  ?fl <- (beer (ninetynine ?bottlenum))
  (test (> ?bottlenum 2))
  =>
  (printout t ?bottlenum " bottles of beer on the wall," t)
  (printout t ?bottlenum " bottles of beer." t)
  (printout t "Take one down, pass it around," t)
  (printout t (- ?bottlenum 1) " bottles of beer on the wall." t)
  (printout t " " t)
  (modify ?fl (ninetynine =(- ?bottlenum 1)))
)
(defrule Bottlestwo ""
  (beer (ninetynine 2))
  ?fl <- (beer (ninetynine ?bottlenum))
  =>
  (printout t ?bottlenum " bottles of beer on the wall," t)
  (printout t ?bottlenum " bottles of beer." t)
  (printout t "Take one down, pass it around," t)
  (printout t (- ?bottlenum 1) " bottle of beer on the wall." t)
  (printout t " " t)
  (modify ?fl (ninetynine =(- ?bottlenum 1)))
)

(defrule Bottlesone ""
  (beer (ninetynine 1))
  ?fl <- (beer (ninetynine ?bottlenum))
  =>
  (printout t ?bottlenum " bottle of beer on the wall," t)
  (printout t ?bottlenum " bottle of beer." t)
  (printout t "Take one down, pass it around," t)
  (printout t "No more bottles of beer on the wall!" t)
)
 
  Programming language: CLIST
 
/* THIS IS WRITTEN IN CLIST - A IBM MVS/TSO BATCH LANGUAGE     
/* THIS LINE IS A COMMENT                                      
/* ALEX V FLINSCH SPARROWHAWK@WORLDNET.ATT.NET 
PROC 0                                                         
   SET BEER=99                                                 
A: WRITE &BEER BOTTLES OF BEER ON THE WALL                     
   WRITE &BEER BOTTLES OF BEER                                 
   WRITE TAKE ONE DOWN AND PASS IT AROUND                      
   SET BEER=&EVAL(&BEER-1)                                     
   IF &BEER ,= 0 THEN GOTO A                                   
   WRITE NO MORE BOTTLES OF BEER ON THE WALL                   
   WRITE NO MORE BOTTLES OF BEER                               
 
  Programming language: CLOS
 
;;;; 99 bottles of beer as a CLOS program.
;;;; Author: Christopher Oliver (oliver@traverse.com)
;;;; Aug 10, 1997

(defconstant *bottles-at-store* 500)
(defconstant *bottles-at-gathering* 99)

(defclass bottle-of-beer () ())

(defclass beer-holder () ((inventory :accessor inventory :initform nil)))

(defclass wall (beer-holder)  ((on-hand :accessor on-hand :initform 0)))

(defclass store (beer-holder) ())

(defmethod consume ((bottle bottle-of-beer))
  (format t "pass it around.~%"))

(defmethod add-to-inventory ((holder beer-holder) (bottle bottle-of-beer))
  (push bottle (inventory holder)))

(defmethod remove-from-inventory ((holder beer-holder))
  (pop (inventory holder)))

(defmethod add-to-inventory :after ((wall wall) (bottle bottle-of-beer))
  (incf (on-hand wall)))

(defmethod remove-from-inventory ((wall wall))
  (let ((bottle (call-next-method)))
    (when bottle
      (format t "~&Take ~:[one~;it~] down, and " (= (on-hand wall) 1))
      (decf (on-hand wall)))
    bottle))

(defmethod count-bottles ((wall wall) &key (long-phrase nil))
  (let ((on-hand (on-hand wall)))
    (format t "~&~:[~@(~R~)~;No more~*~] bottle~p of beer~@[ on the wall~]."
	    (zerop on-hand) on-hand on-hand long-phrase)))

(defmethod remove-from-inventory ((store store))
  (let ((bottle (call-next-method)))
    (if bottle
	(unless (consp (inventory store))
	  (format t "~&(You've exhausted my supply!)~%"))
        (format t "~&(I have nothing left to sell you!)~%"))
    bottle))

(defmethod replenish ((wall wall) (store store))
  (format t "~&Go to the store, and buy some more.")
  (dotimes (number-bought 99)
    (let ((bottle (remove-from-inventory store)))
      (cond (bottle	            (add-to-inventory wall bottle))
	    ((plusp number-bought)  (return-from replenish))
	    (t	                    (error "The end is at hand!"))))))

(defun ninety-nine ()       
  (let ((store (make-instance 'store))
	(wall (make-instance 'wall)))
    (dotimes (ix *bottles-at-store*)
      (add-to-inventory store (make-instance 'bottle-of-beer)))
    (dotimes (ix *bottles-at-gathering*)
      (add-to-inventory wall (make-instance 'bottle-of-beer)))
    (loop
      (progn
	(count-bottles wall :long-phrase t)
	(count-bottles wall)
	(let ((this-bottle (remove-from-inventory wall)))
	  (if this-bottle
	      (consume this-bottle)
	    (replenish wall store)))
	(count-bottles wall :long-phrase t)
	(format t "~&~%")))))
 
  Programming language: CLU
 
% 99 bottles of beer in CLU by dcurtis@lcs.mit.edu

start_up = proc()
   po: stream := stream$primary_output()
   for i: int in int$from_to_by(99, 1, -1) do
      if i = 1 then
         stream$putl(po, int$unparse(i) || " bottle of beer on the wall")
         stream$putl(po, int$unparse(i) || " bottle of beer...")
      else
         stream$putl(po, int$unparse(i) || " bottles of beer on the wall")
         stream$putl(po, int$unparse(i) || " bottles of beer...")
      end
      stream$putl(po, "Take one down, pass it around...")
      end
   stream$putl(po, "\nTime to get more beer!")
   end start_up
 
  Programming language: Cobol
 
 IDENTIFICATION DIVISION.
 PROGRAM-ID.BOTTLES_OF_BEER.
 AUTHOR.DONALD FRASER.
*
 ENVIRONMENT DIVISION.
 CONFIGURATION SECTION.
 SOURCE-COMPUTER. VAX.
 OBJECT-COMPUTER. VAX.
*
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
        SELECT OUTPUT-FILE
                ASSIGN TO BEERS_ON_THE_WALL.
*
 DATA DIVISION.
 FILE SECTION.
 FD OUTPUT-FILE
        LABEL RECORDS ARE OMITTED.
 01 BEERS-OUT                                   PIC X(133).
*
 WORKING-STORAGE SECTION.
 01 FLAGS-COUNTERS-ACCUMULATORS.
        05 FLAGS.
                10 E-O-F                                PIC 9.
                        88 END-OF-FILE                VALUE 1.
        05 COUNTERS.
                10 BOTTLES                      PIC 999
                                                VALUE 0.
 01 RECORD-OUT.
        05 LINE1.
                10 NUMBER-OF-BEERS-1                    PIC ZZ9.
                10                                      PIC X(28)
                                VALUE "BOTTLES OF BEER IN THE WALL ".
                10                                                        PIC
X
                                VALUE ",".
                        10 NUMBER-OF-BEERS-2            PIC ZZ9.
                10                                                        PIC
X.
                10                                      PIC X(17)
                                VALUE "BOTTLES OF BEER.".
        05 LINE2.
                10                                              PIC X(34)
                                VALUE "TAKE ONE DOWN AND PASS IT ARROUND ".
                10 NUMBER-OF-BEERS-3            PIC ZZ9.
                10                                      PIC X.
                10                                      PIC X(28)
                                VALUE "BOTTLES OF BEER IN THE WALL".
*
 PROCEDURE DIVISION.
 DRIVER-MODULE.
      PERFORM INITIALIZATION.
      PERFORM PROCESS UNTIL END-OF-FILE.
      PERFORM TERMINATION.
      STOP RUN.
*
 INITIALIZATION.
        OPEN OUTPUT OUTPUT-FILE.
        ADD 100 TO BOTTLES.
*
 PROCESS.
         IF BOTTLES = 0 THEN
                COMPUTE E-O-F = 1
        ELSE PERFORM WRITE-ROUTINE
        END-IF.
*
 TERMINATION.
        CLOSE OUTPUT-FILE.
*
 WRITE-ROUTINE.
          MOVE BOTTLES TO NUMBER-OF-BEERS-1, NUMBER-OF-BEERS-2.
         COMPUTE BOTTLES = BOTTLES - 1.
         WRITE BEERS-OUT FROM LINE1.
         MOVE BOTTLES TO NUMBER-OF-BEERS-3.
        WRITE BEERS-OUT FROM LINE2.

 
  Programming language: COCOA
 
' COCOA version of 99 Bottles of beer (Bottles.cocoa)
' See http://www.mcmanis.com/~cmcmanis/java/javaworld/examples/BASIC.html
' Philipp Winterberg, http://www.winterbergs.de
'
' How to use:
' 1. Go to http://www.mcmanis.com/~cmcmanis/java/javaworld/examples/BASIC.html
' 2. Copy only the code line below (it is a single line!)
' 3. Paste it into COCOA window
' 4. Press enter and enjoy ;)

for b=99 to 1 step -1:print b;" bottle(s) of beer on the wall,":print b;" 
bottle(s) of beer.":print "Take one down, pass it around,":print (b-1);" 
bottle(s) of beer on the wall.":print " ":next b
 
  Programming language: Cold Fusion (cfscript)
 
By S. Isaac Dealey


<cfscript>
   for ( x = 99 ; x gt 1 ; x = x - 1) {
      WriteOutput("#x# bottles of beer on the wall...<br>#x# bottles of beer!<br>");
      WriteOutput("Take one down, pass it around...<br>";
   }
   WriteOutput("1 bottle of beer on the wall...<br>1 bottle of beer!<br>");
   WriteOutput("Take one down, pass it around...<br>No bottles of beer on the wall");
</cfscript>
 
  Programming language: Cold Fusion (UDF)
 
By S. Isaac Dealey


<cfscript>
   function beerSong(x) {
      b = iif(x gt 1, DE("bottles"), DE("bottle"));
      if (x) {
        WriteOutput("#x# #b# of beer on the wall...<br>#x# #b# of beer!</br>");
        WriteOutput("Take one down, pass it around...<br>";
        beerSong( x - 1 );
      }
      else
      {
        WriteOutput("No bottles of beer on the wall");
      }
   }
   beerSong(99);
</cfscript>
 
  Programming language: Cold Fusion
 
<!---  99 Bottles of Beer in Cold Fusion by Steven Reich tauman@earthlink.net --->
<!---  Additions by Michael Dinowitz --->

<HTML>
<HEAD>
<TITLE>Bottles of Beer</TITLE>
</HEAD>

<BODY>

<CFLOOP INDEX="idx" FROM="99" TO="2" STEP="-1">
<CFOUTPUT>
#idx# Bottles of Beer on the wall, #idx# Bottles of Beer,
<BR>Take one down, pass it around, #Evaluate(idx - 1)# Bottles of 
Beer on the wall
<P>
</CFOUTPUT>
</CFLOOP>
1 Bottle of Beer on the wall, 1 Bottle of Beer,
<BR>Take one down, pass it around, no Bottles of Beer on the wall

</BODY>
</HTML>
 
  Programming language: COMAL
 
Common Algorithmic Language.
0010  // bottles of beer
0020
0030  FOR x# := 99 TO 1 STEP -1 DO
0040     bottles(x#, TRUE)
0050     bottles(x#, FALSE)
0060     PRINT "Take one down, pass it around."
0070     bottles(x#-1, FALSE)
0080  ENDFOR num
0090
0100  END
0110
0120  PROC bottles(num#, wall) CLOSED
0130     PRINT num#;
0140
0150     text$ := "bottle"
0160
0170     IF num# <> 1 THEN
0180        text$ := text$ + "s"
0190     ENDIF
0200
0210     PRINT text$," of beer";
0220
0230     IF wall = TRUE
0240        PRINT "on the wall";
0250     ENDIF
0260
0270     PRINT "."
0280  ENDPROC bottles
 
  Programming language: Common Lisp (format string)
 
;;; The format string in Common Lisp is almost a
;;; language on its own. Here's a Lisp version
;;; that shows its power. Hope you find it 
;;; entertaining.

(in-package "CL-USER")

(defun bottle-song (&optional (in-stock 99) (stream *standard-output*))

  ;; Original idea and primary coding by Geoff Summerhayes
  ;;   <sumrnot@hotmail.com>
  ;; Formatting idea by Fred Gilham <gilham@snapdragon.csl.sri.com>
  ;; Actual formatting & minor recoding by Kent M Pitman
  ;;   <pitman@world.std.com>

  (format

           stream 
         "-----~2%~
          ~{~&~1&~
          ~[~^~:;~
          ~1:*~@(~
          ~R~) bo~
         ttle~:P o~
        f beer on t~
      he wall~01:*~[.~
      ~:;,~%~1:*~@(~R~
      ~) bottle~:*~P ~
      of beer.~%You t~
      ake one down, p~
      ass it around, ~
      ~01%~[*No* more~
      ~:;~:01*~@(~R~)~
      ~] bottle~:*~P ~
      of beer on the ~
      wall.~2&-----~%~
      ~1%~:*~]~]~}~0%"

   (loop for bottle from in-stock downto 0 collect bottle)))


(bottle-song)

 
  Programming language: Common LISP
 
;; Bottles by Rebecca Walpole (walpolr@cs.orst.edu)
;; tested in Austin Kyoto Common Lisp version 1.615
;; Note: the ~p takes care of plurals.
;;
(defun bottles (n)
 "Prints the lyrics to '99 Bottles of Beer'"
(if (< n 1)
    (format t "~%Time to go to the store.~%")
    (progn (format t "~% ~a bottle~:p of beer on the wall." n)
           (format t "~% ~a bottle~:p of beer." n)
           (format t "~% Take one down, pass it around.")
           (format t "~% ~a bottle~:p of beer on the wall.~%" (- n 1))
           (bottles (- n 1))
	   )
  )
)

(bottles 99)
 
  Programming language: ComWic
 
> ComWic version of 99 Bottles of beer (Bottles.cwx)
> See http://www.tcdn.teiher.gr/upload/viewfiles.asp?catid=03
> Philipp Winterberg, http://www.winterbergs.de
>
CLS
MOV 1,99
*LOOP
ECHO 1
ECHO
> bottle(s) of beer on the wall,
ECHO 1
ECHO
> bottle(s) of beer.
> Take one down, pass it around,
SUB 1,1
ECHO 1
ECHO
> bottle(s) of beer on the wall.
IF NUM,$1,<,1,END WICHTELCHEN
> 
GOTO LOOP
 
  Programming language: Concurrent Clean
 
//language Concurrent Clean - lazy pure functional
// Author: Jan Krynicky (jkry3025@comenius.mff.cuni.cz)
module beer
import StdEnv

//run with console and no constructors (don't want to make windows, menu ...)
Start = genbeer 99
 where
  genbeer 0 = ["No more bottles of beer on the wall.\n", //We are all drunk enough.
               "No more bottles of beer.\n",             //so sad!
               "Go to the store and buy some more.\n"    //If you can fin it.
              : genbeer 99]                              
              //Go on, let's drink forever.
  genbeer n = [sn+++" Bottle(s) of beer on the wall, "
               +++ sn +++ " bottle(s) of beer.\n",
               "Take one down and pass it around.\n",
               toString(n-1)+++ " bottle(s) of beer on the wall."
              :genbeer (n-1)]
   where
    ns = toString(n)

//end
 
  Programming language: Cool
 
-- Cool, a language used for teaching compilers
-- http://www.cs.berkeley.edu/~aiken/cool/

-- By Kirsten Chevalier -- krc AT cs DOT berkeley DOT edu

class Beer inherits IO {

  numberOfBeers : Int <- 99;

  song () : Object {
   if (numberOfBeers = 0) then
      out_string("Time to buy more beer!\n")
   else
     {
       out_int(numberOfBeers);
       out_string(" bottles of beer on the wall,\n");
       out_int(numberOfBeers);
       out_string(" bottles of beer\nTake one down, pass it around\n");
       out_int(numberOfBeers);
       out_string(" bottles of beer on the wall.\n");
       numberOfBeers <- numberOfBeers - 1;
       song();
     }
   fi
  };

};

class Main {

  main () : Object {
   (new Beer).song()
  };

};

 
  Programming language: CorVu
 
<a href=http://www.corvu.com.au>CorVu</a> is an integrated business intelligence suite
bottles = 99;

(bottles > 0)
?*
(
	text = ((bottles > 1) ? " bottles" : " bottle");
	display(bottles, text, " of beer on the wall,");
	newline();
	display(bottles, text, " of beer,");
	newline();
	display("Take one down, and pass it around,");
	newline();
	bottles = bottles - 1;
	(bottles > 0)
	?
	(
		text = ((bottles > 1) ? " bottles" : " bottle");
		display(bottles, text, " of beer on the wall.")
	)
	:
	(
		display("No more bottles of beer on the wall.")
	);
	newline(2)
);

display("No more bottles of beer on the wall,");
newline();
display("No more bottles of beer,");
newline();
display("Go to the store and buy some more,");
newline();
display("99 bottles of beer on the wall.");
newline()
 
  Programming language: Cow
 
Written in Sean Heber's Cow programming language:
http://www.bigzaphod.org/cow/

This code written by Greg Nichols

moOMoOMoOMoOMoOmoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMMMmoOMMMMoOMoOMoOMoOMoOMoO
MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMMMmoOMMMommMoOMoOMoOMoOMoO
MoOMoOMoOMoOMoOMoOMoOMMMmoOMMMMoOMoOMMMmoOMMMMoOMoOMoOMoOMoOMoOMoOMoOMoOMoO
MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoO
MoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMoOMMMmoOMMMMoOMMMmOomOomOomOo
mOomOoMMMMoOmoOmoOmoOmoOmoOmoOMMMmoOMMMMoOMoOMMMmoOMMMMoOMMMmoOMMMMoOMMMmoO
MMMMoOMoOMMMmoOMMMMoOMMMmoOMMMMoOMoOMMMmoOMMMMoOMMMmoOMMMMoOMoOMMMmoOMMMMoO
MMMmoOMMMMoOMMMmoOMMMMoOMoOMMMmoOMMMMoOMMMmoOMMMMoOMMMmoOMMMMoOMMMmoOMMMMoO
MoOmOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOoMOOOOMmoO
moOmoOmoOmoOmoOMoomoOmoOmoOmoOmoOmoOmoOmoOmoOMoomoOmoOmoOmoOMooMoomOomOomOo
mOomOomOoMoomOomOomOomOomOoMoomOomOomOomOomOomOomOomOoMMMMOoMOOmoOmoOmoOmoO
moOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOo
mOomOomOomOomOomOomOomOoOOOmooMMMmoOmoOmoOmoOmoOmoOmoOmoOmOomOomOomOomOomOo
MoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOoMoomOomOomOo
mOomOomOomOoMoomoOmoOmoOmoOMoomoOmoOMooMoomoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOo
mOomOomOomOomOomOomOomOomOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoO
moOmoOmoOMoomOoMoomOomOomOomOomOomOomOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoO
moOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOoMoomOomOoMoo
mOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoO
moOMoomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoO
moOmoOMooMoomOomOomOomOomOomOomOomOomOomOoMoomOomOoMoomOoOOMmoOmoOmoOmoOmoO
moOMoomoOmoOmoOmoOmoOmoOmoOmoOmoOMoomoOmoOmoOmoOMooMoomOomOomOomOomOomOoMoo
mOomOomOomOomOoMoomOomOomOomOomOomOomOomOoMMMMOoMOOmoOmoOmoOmoOmoOmoOmoOmoO
moOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOomOomOomOomOo
mOomOomOomOoOOOmooMMMmoOmoOmoOmoOmoOmoOmoOmoOmOomOomOomOomOomOoMoomoOmoOmoO
moOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOoMoomOomOomOomOomOomOomOo
MoomoOmoOmoOmoOMoomoOmoOMooMoomoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOo
mOomOomOomOomOomOomOomOomOoMoomOomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoO
moOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOomOomOomOomOoMoomoOmoOmoO
moOmoOmoOmoOMoomOomOomOomOoMoomOomOomOomOomOomOoMoomOomOoMMMmOoOOOMoOmoOMOo
MOOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOoMoomOomOomOomOomOomOo
MoomOomOomOomOomOomOomOomOomOoOOOmoOOOOmooMMMmOoMOOmoOmoOmoOmoOmoOmoOmoOmoO
moOmoOmoOmoOMoomoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOomOo
mOomOomOomOomOomOomOomOomOoOOOmoomoOmoOmoOMoomoOmoOmoOmoOmoOMoomoOmoOmoOmoO
moOmoOmoOmoOMoomoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOoMoomOomOomOomOomOo
mOomOomOomOomOomOoMoomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOo
mOomOomOomOomOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoo
MoomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoOmoO
moOmoOMoomoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOomOomOomOo
mOomOomOomOoMoomoOmoOmoOMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOoMoo
moOmoOmoOmoOmoOMoomOomOomOomOomOomOoMoomOomOomOomOomOomOomOoMoomOomOomOomOo
MoomOomOoMoomOoMOoOOMmoOmoOmoOmoOmoOmoOMoomoOmoOmoOmoOmoOmoOmoOmoOmoOMoomoO
moOmoOmoOMooMoomOomOomOomOomOomOoMoomOomOomOomOomOoMoomOomOomOomOomOomOomOo
mOoMMMMOoMOOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOo
mOomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOoOOOmooMMMmoOmoOmoOmoOmoOmoO
moOmoOmOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOo
mOomOomOomOoMoomOomOomOomOomOomOomOoMoomoOmoOmoOmoOMoomoOmoOMooMoomoOmoOmoO
moOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOoMoomoOmoO
moOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOoMoomOomOomOomOomOomOomOomOomOomOomOo
mOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOo
mOomOomOomOoMoomOomOoMoomOomOomOomOomOomOoMoomoOmoOmoOmoOmoOmoOmoOmoOmoOmoO
moOmoOmoOmoOmoOmoOmoOmoOmoOMoomOomOomOomOomOomOomOomOomOomOomOomOomOomOomOo
mOoMoomoOmoOmoOmoOmoOmoOmoOmoOMooMoomOomOomOomOomOomOomOomOomOoMoomOomOomOo
MooMoomOomoo
 
  Programming language: CRM114
 
# 99 Bottles for "the CRM114 Discriminator"
# Dave Plonka - plonka@doit.wisc.edu, Mar 15 2003
# with modifications by WSY 

window
isolate (:n:)
alter (:n:) /99/
isolate (:s:)
alter (:s:) /s/

{
   # print starting preamble of verse
   output /:*:n: bottle:*:s: of beer on the wall,:*:_nl:/
   output /:*:n: bottle:*:s: of beer:*:_nl:/

   # actually decrement the bottles
   output /take one down, pass it around,:*:_nl:/
   syscall ( :*:n:-1:*:_nl: ) (:n:) /bc/
   # remove the trailing new-line:
   match (:n:) [:n:] /[0-9]+/

   # handle the one case (get rid of the "s")
   {
      match [:n:] /^1$/
      alter (:s:) //
   }

   # handle the zero case:
   match <absent> [:n:] /^0$/

   #  and if we get to here, we're nonzero on bottles, so go round again.
   output /:*:n: bottle:*:s: of beer on the wall.:*:_nl::*:_nl:/
   liaf
}
output /no more bottles of beer on the wall.:*:_nl:/
 
  Programming language: CSP
 
-- CSP - Version of 99 Bottles of Beer
-- uses output of FDR2 refinement checker
-- by Werner Renhardt werner@kangaroo.at
-- 12/05/2002
-- 
-- execute: fdr batch -trace beer99.csp > beer99.txt

datatype Text = bottles_of_beer_on_the_wall | bottles_of_beer |
                bottle_of_beer_on_the_wall | bottle_of_beer
nametype Text2 = {0..99}.Text

channel Still : Text2
channel So : Text2
channel Go_to_the_store_and_buy_some_more
channel Take_one_down_and_pass_it_around
channel No_more_bottles_of_beer_on_the_wall
channel No_more_bottles_of_beer


BEERCRATE(0) = No_more_bottles_of_beer_on_the_wall ->
	       No_more_bottles_of_beer ->
	       Go_to_the_store_and_buy_some_more
	        -> STOP

BEERCRATE(1) = Still!1.bottle_of_beer_on_the_wall -> 
               Still!1.bottle_of_beer -> 
               Take_one_down_and_pass_it_around ->
	       No_more_bottles_of_beer_on_the_wall ->
               BEERCRATE(0)

BEERCRATE(n) = Still!n.bottles_of_beer_on_the_wall -> 
               Still!n.bottles_of_beer -> 
               Take_one_down_and_pass_it_around ->
	       So!(n-1).bottles_of_beer_on_the_wall ->
               BEERCRATE(n-1)

BEER99 = BEERCRATE(99)

-- a deadlock occurs after emptying 99 beers ( -> STOP)
-- and the corresponding trace will be delivered as output

assert BEER99 :[ deadlock free [F] ]


---------- snip ---------

Part of the output beer99.txt
---------
Checking beer99.csp
xfalse
BEGIN TRACE example=0 process=0
Still.99.bottles_of_beer_on_the_wall
Still.99.bottles_of_beer
Take_one_down_and_pass_it_around
So.98.bottles_of_beer_on_the_wall
Still.98.bottles_of_beer_on_the_wall
...
...
So.1.bottles_of_beer_on_the_wall
Still.1.bottle_of_beer_on_the_wall
Still.1.bottle_of_beer
Take_one_down_and_pass_it_around
No_more_bottles_of_beer_on_the_wall
No_more_bottles_of_beer_on_the_wall
No_more_bottles_of_beer
Go_to_the_store_and_buy_some_more
END TRACE example=0 process=0
---------
 
  Programming language: CUPL
 
CUPL is the Cornell University Programming Language (c. 1966)

COMMENT	99 BOTTLES IN CUPL (CORNELL UNIVERSITY PROGRAMMING LANGUAGE, C. 1966)
COMMENT	DAVE PLONKA - PLONKA@DOIT.WISC.EDU
COMMENT	FEB 17 1998
	LET N = 99
	PERFORM SONG WHILE N GT 2
LINES	BLOCK
	WRITE /N, ' BOTTLES OF BEER ON THE WALL,'
	WRITE /N, ' BOTTLES OF BEER,'
LINES	END
LINE	BLOCK
	WRITE 'TAKE ONE DOWN, PASS IT AROUND,'
LINE	END
SONG	BLOCK
	PERFORM LINES
	PERFORM LINE
	LET N = N - 1
	WRITE /N, ' BOTTLES OF BEER ON THE WALL.'
	WRITE ''
SONG	END
	PERFORM LINES
	PERFORM LINE
	WRITE '1 BOTTLE OF BEER ON THE WALL.'
	WRITE ''
	WRITE '1 BOTTLE OF BEER ON THE WALL,'
	WRITE '1 BOTTLE OF BEER,'
	PERFORM LINE
	WRITE 'NO BOTTLES OF BEER ON THE WALL.'
	STOP
 
  Programming language: Curl
 
|| Curl version of 99 Bottles of beer (Bottles.curl)
|| http://www.curl.com/html/
|| Philipp Winterberg, http://www.winterbergs.de
||
{curl 1.7 applet}
{value
    let b:int=99
    let song:VBox={VBox}
    {while b > 0 do
        {song.add b & " bottle(s) of beer on the wall,"}
        {song.add b & " bottle(s) of beer."}
        {song.add "Take one down, pass it around,"}
        set b = b - 1
        {song.add b & " bottle(s) of beer on the wall."}
    }
    song
}

 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:31