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
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
Hinek said on 10/14/05 13:24:56
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
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 ... ?