                            (* Chapter 5 - Programming exercise 2 *)
program Try_Recursion;

var Count : integer;

procedure Print_And_Decrement(Index : integer);
begin
   Writeln('The value of the index is ',Index:3);
   Index := Index - 1;
   if Index > 0 then
      Print_And_Decrement(Index);
   Writeln('The value of the index is now ',Index:3);
end;

begin  (* main program *)
   Count := 7;
   Print_And_Decrement(Count);
end.  (* main program *)




{ Result of execution

The value of the index is   7
The value of the index is   6
The value of the index is   5
The value of the index is   4
The value of the index is   3
The value of the index is   2
The value of the index is   1
The value of the index in now 0
The value of the index in now 1
The value of the index in now 2
The value of the index in now 3
The value of the index in now 4
The value of the index in now 5
The value of the index in now 6

}
