home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 10 - Programming exercise 1
- with Text_IO;
- use Text_IO;
-
- procedure CH10_1 is
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- use Int_IO;
-
- N : INTEGER := 10;
- Dummy1 : array(INTEGER range 1..7) of BOOLEAN;
- Dummy2 : array(INTEGER range -21..N) of BOOLEAN;
- Dummy3 : array(-21..N) of BOOLEAN;
-
- type MY_ARRAY is array(1..5) of INTEGER;
- type NEW_ARRAY_TYPE is array(12..27) of INTEGER;
-
- Total : MY_ARRAY;
- First : MY_ARRAY;
- Second : MY_ARRAY;
- Funny : array(1..5) of INTEGER;
- X,Y : NEW_ARRAY_TYPE;
- Fourth_Value : INTEGER renames First(4);
-
- begin
- for Index in 12..27 loop
- X(Index) := Index + 7;
- end loop;
-
- Y := X; -- These are now assignment compatible
-
- First(1) := 12;
- First(2) := 16;
- First(3) := First(2) - First(1);
- Fourth_Value := -13;
- First(5) := 16 - 2*First(2);
-
- for Index in 1..5 loop
- Second(Index) := 3 * Index + 77;
- end loop;
-
- Total := First;
- if Total = First then
- Put("Both arrays are the same size and contain ");
- Put_Line("the same values in all elements.");
- end if;
-
- for Index in 1..5 loop
- Total(Index) := Total(Index) + Second(Index);
- Funny(Index) := Total(Index) + First(6 - Index);
- Put("The array values are");
- Put(Total(Index));
- Put(Funny(Index));
- New_Line;
- end loop;
- end CH10_1;
-
-
-
-
- -- Result of execution
-
- -- Both arrays are the same size and contain the same values in...
- -- The array values are 92 76
- -- The array values are 99 86
- -- The array values are 90 94
- -- The array values are 76 92
- -- The array values are 76 88
-
-