home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / recurson.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  929 b   |  42 lines

  1.                                        -- Chapter 18 - Program 3
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Recurson is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    Index : INTEGER;
  11.  
  12.    procedure Print_And_Decrement(Value : in     INTEGER) is
  13.    New_Value : INTEGER;
  14.    begin
  15.       Put("The value of the index is now");
  16.       Put(Value);
  17.       New_Line;
  18.       New_Value := Value - 1;
  19.       if New_Value > 0 then
  20.          Print_And_Decrement(New_Value);
  21.       end if;
  22.    end Print_And_Decrement;
  23.  
  24. begin
  25.    Index := 7;
  26.    Print_And_Decrement(Index);
  27. end Recurson;
  28.  
  29.  
  30.  
  31.  
  32. -- Result of execution
  33.  
  34. -- The value of the index is now     7
  35. -- The value of the index is now     6
  36. -- The value of the index is now     5
  37. -- The value of the index is now     4
  38. -- The value of the index is now     3
  39. -- The value of the index is now     2
  40. -- The value of the index is now     1
  41.  
  42.