-- Chapter 4 - Programming exercixe 2 -- Chapter 4 - Program 2 with Text_IO; use Text_IO; procedure Ch04_2 is package Int_IO is new Text_IO.Integer_IO(INTEGER); use Int_IO; package Enum_IO is new Text_IO.Enumeration_IO(BOOLEAN); use Enum_IO; Index, Count : INTEGER := 12; Truth, Lies, Question : BOOLEAN; begin Truth := Index = Count; -- This is TRUE Put("Truth now has the value of "); Put(Truth); New_Line; Lies := Index < Index; -- This is FALSE Put("Lies now has the value of "); Put(Lies); New_Line; -- Examples of all BOOLEAN operators Question := Index = Count; -- Equality Question := Index /= Count; -- Inequality Question := Index < Count; -- Less than Question := Index <= Count; -- Less than or equal Question := Index > Count; -- Greater than Question := Index >= Count; -- Greater than or equal Put("Question now has the value of "); Put(Question); New_Line; -- Examples of composite BOOLEAN expressions Question := Index = 12 and Count = 12 and Truth and TRUE; Question := Index /= 12 or FALSE or Count > 3 or Truth; Question := (Truth or Lies) and (Truth and not Lies); Question := Truth xor Lies; Put("Question now has the value of "); Put(Question); New_Line; -- now for short circuit evaluation Question := Index /= Count and then Index = 9/(Index - Count); Question := Index = Count or else Index = 9/(Index - Count); Question := (Index = Count) or else (Index = 9/(Index - Count)); Put("Question now has the value of "); Put(Question); New_Line; end Ch04_2; -- Result of execution -- Truth now has the value of TRUE -- Lies now has the value of FALSE -- Question now has the value of TRUE -- Question now has the value of TRUE -- Question now has teh value of TRUE