-- File: demo1.ada -- Demonstrate : -- Arrays -- Loops -- Subprograms: Procedures & Functions -- Tick Marks -- Ranges -- IN membership -- Boolean Operator WITH Text_IO; USE Text_IO; PROCEDURE demo1 IS package Number is new Integer_IO (Integer); -- pkg for reading int use Number; type IntList is array (1..10) of Integer; List : IntList; Index, Value : Integer; FUNCTION GetElt(aList: in IntList; index :in Integer) return Integer is BEGIN return(aList(index)); END GetElt; PROCEDURE SetElt(aList: IN OUT IntList; index , value: IN Integer) is BEGIN aList(index):=value; END SetElt; PROCEDURE PrintList(aList: IN IntList) is BEGIN Text_IO.Put(Item=>"Items in the array"); Text_IO.New_Line; -- Example of tick mark for low & high for i in List'First .. List'Last Loop Put(List(i),0); -- min field width Text_IO.Put(" "); END Loop; Text_IO.New_Line; END PrintList; BEGIN -- code of main procedure -- Example of tick mark for entire range for i in List'Range Loop List(i):=i; END Loop; PrintList(List); -- Example of do loop; wait! No do loop...must use while -- for this example, must be sentinel terminated Text_IO.Put("You may change values..."); Text_IO.Put("Enter the Index to Alter (0 Quits) >"); Get(Index); -- Loop while not sentinel and Index in legal range while Index /= 0 AND Index IN List'Range loop Text_IO.Put("Present Value: "); Put(GetElt(List,Index)); Text_IO.New_Line; Text_IO.Put("Enter the Value >"); Get(Value); SetElt(List,Index,Value); PrintList(List); Text_IO.Put("Enter the Index to Alter (0 Quits) >"); Get(Index); END Loop; Text_IO.New_Line; END demo1;