home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / answers / ch09_2.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.4 KB  |  52 lines

  1.                         -- Chapter 9 - Programming exercise 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure CH09_2 is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    Dog, Cat : INTEGER;
  11.    Pig, Cow : FLOAT;
  12.  
  13. begin
  14.    My_Loop:
  15.    for Index in 1..10 loop
  16.       Put("The value of Index is");
  17.       Put(Index,3);
  18.  
  19.       declare
  20.          START : constant INTEGER := Index;
  21.          STOP  : constant INTEGER := START + 5;
  22.          Count_Stuff : INTEGER;
  23.       begin
  24.          Count_Stuff := START + STOP + Index + 222;
  25.          Put(" --->");
  26.          for Index in START..STOP loop
  27.             Put(My_Loop.Index,5);
  28.          end loop;
  29.       end;
  30.  
  31.       New_Line;
  32.    end loop My_Loop;
  33.  
  34. end CH09_2;
  35.  
  36.  
  37.  
  38.  
  39. -- Result of execution
  40.  
  41. -- The value of Index is  1 --->    1    1    1    1    1    1
  42. -- The value of Index is  2 --->    2    2    2    2    2    2
  43. -- The value of Index is  3 --->    3    3    3    3    3    3
  44. -- The value of Index is  4 --->    4    4    4    4    4    4
  45. -- The value of Index is  5 --->    5    5    5    5    5    5
  46. -- The value of Index is  6 --->    6    6    6    6    6    6
  47. -- The value of Index is  7 --->    7    7    7    7    7    7
  48. -- The value of Index is  8 --->    8    8    8    8    8    8
  49. -- The value of Index is  9 --->    9    9    9    9    9    9
  50. -- The value of Index is 10 --->   10   10   10   10   10   10
  51.  
  52.