Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Turbo Pascal

(for DOS)

Date:04/20/05
Author:Philipp Winterberg
URL:http://www.winterbergs.de/
Comments:2
Info:n/a
Score: (2.62 in 13 votes)
{ Turbo Pascal version of 99 Bottles of beer (Bottles.pas) }
{ Philipp Winterberg, http://www.winterbergs.de }

program Bottles;

var b: byte;

function plural(anz_flaschen: byte): string;
begin
  if anz_flaschen <> 1
    then plural:= 's'
    else plural:= ''
end; {plural}

begin
  b:= 99;
  repeat
    writeln(b, ' bottle' + plural(b) + ' of beer on the wall, ');
    writeln(b, ' bottle' + plural(b) + ' of beer.');
    writeln('Take one down, pass it around,');
    writeln((b-1), ' bottle' + plural(b-1) + ' of beer on the wall.');
    dec(b)
  until b = 0;
  readln;
end. {Bottles}

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
for WindowsPhilipp Winterberg04/20/052

Comments

>>  Hinek said on 10/14/05 13:24:56

Hinek repeat
writeln(b, ' bottle' + plural(b) + ' of beer on the wall, ');
writeln(b, ' bottle' + plural(b) + ' of beer.');
writeln('Take one down, pass it around,');
dec(b);
writeln(b), ' bottle' + plural(b) + ' of beer on the wall.');
until b = 0;

Would be better: why use (b-1) when you decrement b in the line after ... ?

>>  Hinek said on 10/14/05 13:26:06

Hinek repeat
writeln(b, ' bottle' + plural(b) + ' of beer on the wall, ');
writeln(b, ' bottle' + plural(b) + ' of beer.');
writeln('Take one down, pass it around,');
dec(b);
writeln(b, ' bottle' + plural(b) + ' of beer on the wall.');
until b = 0;

Would be better: why use (b-1) when you decrement b in the line after ... ?

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!

Name:

eMail:

URL:

Security Code:
  
Comment: