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

  1.                          -- Chapter 15 - Programming example 3
  2.  
  3.                  -- Interface of NewAdderPkg
  4. package NewAdderPkg is
  5.    type MY_ARRAY is array(INTEGER range <>) of FLOAT;
  6.    procedure Add_Em_Up(In_Dat : in     MY_ARRAY;
  7.                        Sum    :    out FLOAT);
  8. end NewAdderPkg;
  9.  
  10.  
  11.                  -- Implementation of NewAdderPkg
  12. package body NewAdderPkg is
  13.    procedure Add_Em_Up(In_Dat : in     MY_ARRAY;
  14.                        Sum    :    out FLOAT) is
  15.    Total : FLOAT;
  16.    begin
  17.       Total := 0.0;
  18.       for Index in In_Dat'FIRST..In_Dat'LAST loop
  19.          Total := Total + In_Dat(Index);
  20.       end loop;
  21.       Sum := Total;
  22.    end Add_Em_Up;
  23. end NewAdderPkg;
  24.  
  25.  
  26.  
  27.  
  28. -- Result of execution
  29.  
  30. -- (This is not a stand alone package, so it has no output.)
  31.  
  32.