home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / except1.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  956 b   |  43 lines

  1.                                        -- Chapter 17 - Program 1
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Except1 is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    procedure Divide_Loop is
  11.    Divide_Result : INTEGER;
  12.    begin
  13.       for Index in 1..8 loop
  14.          Put("Index is");
  15.          Put(Index,3);
  16.          Put(" and the answer is");
  17.          Divide_Result := 25/(4 - Index);
  18.          Put(Divide_Result);
  19.          New_Line;
  20.       end loop;
  21.    exception
  22.       when Numeric_Error => Put_Line(" Divide by zero error.");
  23.    end Divide_Loop;
  24.  
  25. begin
  26.    Put_Line("Begin program here.");
  27.    Divide_Loop;
  28.    Put_Line("End of program.");
  29. end Except1;
  30.  
  31.  
  32.  
  33.  
  34. -- Result of Execution
  35.  
  36. -- Begin program here.
  37. -- Index is  1 and the answer is     8
  38. -- Index is  2 and the answer is    12
  39. -- Index is  3 and the answer is    25
  40. -- Index is  4 and the answer is Divide by zero error.
  41. -- End of program.
  42.  
  43.