99 Bottles of Beer/Pascal: Difference between revisions

Content added Content deleted
(moving code from main task-page to sub-page)
(→‎{{header|Pascal}}: Modified so that it's a stand-alone program, and eliminated "Format" since not all Pascals support that. Simplified code a little bit.)
Line 99: Line 99:


=={{header|Pascal}}==
=={{header|Pascal}}==
<lang pascal>procedure BottlesOfBeer;
<lang pascal>program BottlesOfBeer;
var
var
i: Integer;
i: Integer;
begin
begin
for i := 99 downto 1 do
for i := 99 downto 1 do
begin
if i = 1 then begin
writeln('One bottle of beer on the wall');
if i = 1 then
writeln('One bottle of beer');
begin
WriteLn('1 bottle of beer on the wall');
writeln('Take one down, pass it around');
WriteLn('1 bottle of beer');
writeln('No more bottles of beer on the wall');
WriteLn('Take one down, pass it around');
end else begin
WriteLn('No more bottles of beer on the wall');
writeln(i, ' bottles of beer on the wall');
writeln(i, ' bottles of beer');
Exit;
writeln('Take one down, pass it around');
end;
if i = 2 then
WriteLn(Format('%d bottles of beer on the wall', [i]));
WriteLn(Format('%d bottles of beer', [i]));
writeln('One bottle of beer on the wall')
else
WriteLn('Take one down, pass it around');
WriteLn(Format('%d bottles of beer on the wall', [Pred(i)]));
writeln(i - 1, ' bottles of beer on the wall')
WriteLn('');
end;
end. </lang>
end;
end;</lang>