| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

10gbPascal

Page history last edited by Mike Leishman 16 years, 6 months ago

Written by Mike Leishman

program greenbottles;

uses crt;

var number_of_bottles:integer;
    bottle_state_singular : boolean;
    bottle_value: string;

begin
     bottle_state_singular := false;
     bottle_value := 'bottles';
     number_of_bottles := 10;
     repeat
         writeln(number_of_bottles, ' green ', bottle_value, ' hanging on the wall');
         writeln(number_of_bottles, ' green ', bottle_value, ' hanging on the wall');
         writeln('now if one green bottle should accidently fall');
         dec(number_of_bottles);
         bottle_state_singular := number_of_bottles = 1;
         if bottle_state_singular then
            bottle_value := 'bottle'
         else
            bottle_value := 'bottles';
         writeln('there''d be ', number_of_bottles, ' green ', bottle_value, ' hanging on the wall');
         writeln;
      until number_of_bottles = 0;
end.


Note: number_of_bottles := 10; could be replaces with 
Readln(‘How many bottles to start?’, number_of_bottles); 

 

Written by Mark W

program bottles01;

uses wincrt;

var bottles, countx : integer;
const max = 101 ;

begin
     for countx := 1 to (max-1) do
       begin
             bottles := max - countx;
             writeln (bottles, ' green bottles hanging on the wall');
             writeln (bottles, ' green bottles hanging on the wall');
             writeln('and if one green bottle should accidently fall');
             writeln ('there d be ',(bottles-1), ' green bottles hanging on the wall');
             writeln
       end;

end.

Comments (0)

You don't have permission to comment on this page.