The Ada Program: cond.adb

  1 -- cond.adb:  some different "if" statements
  2 
  3 with Ada.Text_IO; use Ada;
  4 
  5 procedure Cond is
  6 
  7    A: constant Float := 3.2;
  8    B: constant Float := 4.5;
  9 
 10 begin
 11 
 12    if A>1.3 then
 13       Text_IO.Put_Line ("A is larger than 1.3");
 14    end if;
 15 
 16    if abs B < 5.2 then
 17       Text_IO.Put_Line ("Either it is, or ...");
 18    else
 19       Text_IO.Put_Line ("... it isn't!");
 20    end if;
 21 
 22    if A>5.7 then
 23       -- A>5.7
 24       null;
 25    elsif B<2.3 then
 26       -- not(A>5.7) and B<2.3
 27       null;
 28    elsif A>B then
 29       -- not(A>5.7) and not(B<2.3) and A>B,
 30       -- or equivalently, 2.3 <= B < A <= 5.7
 31       null;
 32    else
 33       -- not(A>5.7) and not(B<2.3) and not(A>B)
 34       Text_IO.Put_Line ("This is confusing!");
 35    end if;
 36 
 37 end Cond;