Contents | Prev | Next

5.15.4 boolean type

Description

boolean is the type identifier for a built-in enumerated type with two values false and true defined as below:

   boolean = (false, true);

The ordinal value of false is zero and the ordinal value of true is one. The conditional statement:

 and the looping statements:

 use expressions of boolean type. The operators:

 operate on expressions of boolean type.

Example

For example below is a simple program that illustrates using the built-in type boolean:

program Teenager(input, output);
var
   age : integer;
   teenager : boolean;
begin
   write('How old are you?');
   readln(age);
   teenager := (age >= 13) and (age <= 19);
   if teenager then
      writeln('Congratulations!!! You are a teenager')
   else
      writeln('Sorry. You are not a teenager')
end.

Portability

Operating Systems: All
Standard Pascal: Yes

Contents | Prev | Next