Written some cool source code? Upload it to Programmer's Heaven.

View \BOOLMATH.PAS

This is the second disk of the PASCAL TUTOR system. It has the

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 3 - Program 6 *)
program Illustrate_What_Boolean_Math_Looks_Like;

   (* notice the program name, it can be up to 63 characters long.
      Variables can also be very long as we will see below *)


var A,B,C,D : boolean;
    A_Very_Big_Boolean_Name_Can_Be_Used : boolean;
    Junk,Who : integer;

begin
   Junk := 4;
   Who := 5;
   A := Junk = Who;    {since Junk is not equal to Who, A is false}
   B := Junk = (Who - 1){This is true}
   C := Junk < Who;        {This is true}
   D := Junk > 10;         {This is false}
   A_Very_Big_Boolean_Name_Can_Be_Used := A or B; {Since B is true,
                                                  the result is true}

   Writeln('result A is ',A);
   Writeln('result B is ',B);
   Writeln('result C is ',C);
   Writeln('result D is ',D:12); {This answer will be right justified
                                  in a 12 character field}

   Writeln('result A_Very_Big_Boolean_Name_Can_Be_Used is ',
                   A_Very_Big_Boolean_Name_Can_Be_Used);

                      (* Following are a few boolean expressions. *)
   A := B and C and D;
   A := B and C and not D;
   A := B or C or D;
   A := (B and C) or not (C and D);
   A := (Junk = Who - 1) or (Junk = Who);
end.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.