Yurttas/PL/IL/Ada-95/F/01/PU/03.html

Revision as of 04:44, 5 November 2013 by MassBot1 (talk | contribs) (Created page with "{| width="100%" cellpadding="4" | class="y01" | <span class="b10"> ada-95 programming language fundamentals </span> | class="y01" | <div class="right"><span class="h06b"> 1...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
ada-95 programming language fundamentals
1. program units and overall structure

  • package unit is composed of two parts: specification and body as follows:



--

-- date   : January 1, 2000.
-- author : Salih Yurttas.

-- package body
--
-- minni_p.adb


package body Minimum_of_N_Integers_P is

  package Int_IO is new Integer_IO(Integer);
  use Int_IO;

  procedure Get_Integer_List(K : out Integer;
                             D : out Integer_List) is

    In_File_P : File_Type;

    I : Integer := 0;

  begin

    Open(In_File_P, In_File, "in.txt");

    while not End_of_File(In_File_P)
    loop
      I := I + 1;
      Get(In_File_P, D(I));
    end loop;
    K := I;

    Close(In_File_P);

  end Get_Integer_List;

  procedure Find_Min_of_Integer_List(Min,
                                     J    : out Integer;
                                     K    : in Integer;
                                     D    : in ListI) is
    M : Integer;

  begin

    M := D(1);
    J := 1;
    for I in 2..K
    loop
      if D(I)then
        M := D(I);
        J := I;
      end if;
    end loop;
    Min := M;

  end Find_Minimum_of_Integer_List;

  procedure Put_Minimum_of_Integer_List(Min,
                                        J    : in Integer) is
    Out_File_P : File_Type;

  begin

    Create(Out_File_P, Out_File, "out.txt");

    Put(Out_File_P,"D(");
    Put(Out_File_P,J,1);
    Put(Out_File_P,") = ");
    Put(Out_File_P,Min,5);
    Put(Out_File_P," is the minimum of the list.");

    Close(Out_File_P);

  end Put_Minimum_of_Integer_List;

end Minimum_of_N_Integers_P;

<< | >>

contents << | >> flow of control


Dr.Salih Yurttas