home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / ada_1 / Examples_demos_ada_roots < prev    next >
Encoding:
Text File  |  1992-10-01  |  748 b   |  31 lines

  1. WITH Text_IO;
  2. WITH My_Int_IO;
  3. WITH My_Flt_IO;
  4. WITH Math;
  5. PROCEDURE SquareRoots IS
  6.  
  7.  -- Illustrates the square root function provided by Math
  8.  
  9.   MaxNumber : CONSTANT Positive := 20;
  10.   FltNum    : Float;
  11.  
  12. BEGIN  -- SquareRoots   
  13.  
  14.   Text_IO.Put (Item => "Number  Square Root");
  15.   Text_IO.New_Line;
  16.   Text_IO.Put (Item => "------  -----------");
  17.   Text_IO.New_Line;
  18.  
  19.   FltNum := 1.0;
  20.   FOR Number IN 1..MaxNumber LOOP
  21.     My_Int_IO.Put (Item => Number, Width => 3);
  22.     My_Flt_IO.Put (Item => Math.Sqrt (Float(Number)), 
  23.                    Fore => 7, Aft => 5, Exp => 0);
  24.     My_Flt_IO.Put (Item => Math.Sqrt (FltNum), 
  25.                    Fore => 7, Aft => 5, Exp => 0);
  26.     Text_IO.New_Line;
  27.     FltNum := FltNum + 1.0;
  28.   END LOOP;
  29.  
  30. END SquareRoots;
  31.