home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / moreints.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  2.0 KB  |  67 lines

  1.                                        -- Chapter 3 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure MoreInts is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    Index_1                   : INTEGER;
  11.    Index_2, Index_3, Index_4 : INTEGER;
  12.    Cat                       : INTEGER := 12;
  13.    Dog                       : INTEGER := -5;
  14.    Pig, Hog, Sow             : INTEGER := 1000;
  15.  
  16. begin
  17.  
  18.    Index_1 := Cat + 4;                -- Index_1 is 16
  19.    Index_2 := Dog - 3;                -- Index_2 is -8
  20.    Index_3 := Pig * 7;                -- Index_3 is 7000
  21.    Index_4 := Pig / 300;              -- Index_4 is 3
  22.    Put("Index_1 = "); Put(Index_1); New_Line;
  23.    Put("Index_2 = "); Put(Index_2); New_Line;
  24.    Put("Index_3 = "); Put(Index_3); New_Line;
  25.    Put("Index_4 = "); Put(Index_4); New_Line(2);
  26.  
  27.    Index_1 := 5 * Cat - Pig / 4 ;     -- Index_1 is -190
  28.    Index_2 := (5 * Cat) - (Pig / 4);  -- Index_2 is -190
  29.    Index_3 := Pig mod 3;              -- Index_3 is 1
  30.    Index_4 := Pig rem 3;              -- Index_4 is 1
  31.    Put("Index_1 = "); Put(Index_1); New_Line;
  32.    Put("Index_2 = "); Put(Index_2); New_Line;
  33.    Put("Index_3 = "); Put(Index_3); New_Line;
  34.    Put("Index_4 = "); Put(Index_4); New_Line(2);
  35.  
  36.    Index_1 := abs(Dog);               -- Index_1 is 5
  37.    Index_2 := Cat**3;                 -- Index_2 is 1728
  38.    Index_3 := (Cat-5)**(abs(Dog)-2);  -- Index_3 is 343
  39.    Index_4 := -Index_3;               -- Index_4 is -343
  40.    Put("Index_1 = "); Put(Index_1); New_Line;
  41.    Put("Index_2 = "); Put(Index_2); New_Line;
  42.    Put("Index_3 = "); Put(Index_3); New_Line;
  43.    Put("Index_4 = "); Put(Index_4); New_Line(2);
  44.  
  45. end MoreInts;
  46.  
  47.  
  48.  
  49.  
  50. -- Result of execution
  51.  
  52. -- Index_1 =     16
  53. -- Index_2 =     -8
  54. -- Index_3 =   7000
  55. -- Index_4 =      3
  56. --
  57. -- Index_1 =   -190
  58. -- Index_2 =   -190
  59. -- Index_3 =      1
  60. -- Index_4 =      1
  61. --
  62. -- Index_1 =      5
  63. -- Index_2 =   1728
  64. -- Index_3 =    343
  65. -- Index_4 =   -343
  66.  
  67.