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

  1.                         -- Chapter 18 - Programming exercise 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure CH18_2 is
  6.  
  7. Data_Point : INTEGER;
  8.  
  9. package Int_IO is new Text_IO.Integer_IO(INTEGER);
  10. use Int_IO;
  11.  
  12. Procedure Increment(In_Val : in out INTEGER);
  13.  
  14. procedure Display(Dis_Val : in out INTEGER) is
  15. begin
  16.    Put("The value of the variable is now ");
  17.    Put(Dis_Val);
  18.    New_Line;
  19.    Increment(Dis_Val);
  20. end Display;
  21.  
  22. procedure Increment(In_Val : in out INTEGER) is
  23. begin
  24.    if In_Val < 8 then
  25.       In_Val := In_Val + 1;
  26.       Display(In_Val);
  27.    end if;
  28. end Increment;
  29.  
  30. begin
  31.    Data_Point := 1;
  32.    Increment(Data_Point);
  33. end CH18_2;
  34.  
  35.  
  36.  
  37.  
  38. -- result of execution
  39.  
  40. -- The value of the variable is now     2
  41. -- The value of the variable is now     3
  42. -- The value of the variable is now     4
  43. -- The value of the variable is now     5
  44. -- The value of the variable is now     6
  45. -- The value of the variable is now     7
  46. -- The value of the variable is now     8
  47.  
  48.