while loop: example 1

Here is another program that prints out the numbers from 1 to 10.
program whileloop1;

{
  This program demonstrates a "while" loop.  It uses the
  loop to print out the numbers from 1 to 10.
}

var
  i : integer;  { looping variable }

begin
  i := 1;  { initialize i }

  while i <= 10 do
    begin
      writeln(i);
      i := i + 1    { increment i }
    end;
end.

Below we show a compilation and run of the program.

% pc whileloop1.p 

% a.out
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10

CS101 - while loop: example 1 / Robert I. Pitts / rip@cs.bu.edu