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

  1.                           -- Chapter 4 - Programming exercise 1
  2.                                        -- Chapter 4 - Program 1
  3. with Text_IO;
  4. use Text_IO;
  5.  
  6. procedure Ch04_1 is
  7.  
  8.    package Enum_IO is new Text_IO.Enumeration_IO(BOOLEAN);
  9.    use Enum_IO;
  10.  
  11.    One   : INTEGER := 1;
  12.    Two   : INTEGER := 2;
  13.    Three : INTEGER := 3;
  14.  
  15.    Is_It : BOOLEAN := TRUE;      -- initialized
  16.    Which : BOOLEAN;              -- uninitialized
  17.  
  18. begin
  19.  
  20.    Which := TRUE;
  21.    Put("Which now has the value of ");
  22.    Put(Which);
  23.    New_Line;
  24.    Which := FALSE;
  25.    Put("Which now has the value of ");
  26.    Put(Which);
  27.    New_Line;
  28.  
  29.    Is_It := (One + 1) = Two;
  30.    Put("Is_It now has the value of ");
  31.    Put(Is_It);
  32.    New_Line;
  33.    Is_It := One /= Two;
  34.    Put("Is_It now has the value of ");
  35.    Put(Is_It);
  36.    New_Line;
  37.    Is_It := One + Two >= Three;
  38.    Put("Is_It now has the value of ");
  39.    Put(Is_It);
  40.    New_Line;
  41.  
  42. end Ch04_1;
  43.  
  44.  
  45.  
  46.  
  47. -- Result of execution
  48.  
  49. -- Which now has the value of TRUE
  50. -- Which now has the value of FALSE
  51. -- Is_It now has the value of TRUE
  52. -- Is_It now has the value of TRUE
  53. -- Is_It now has the value of TRUE
  54.  
  55.