In a previous article, Mytour introduced you to operators in Pascal and various data types. In this article, Mytour continues the exploration with a focus on Boolean data type in Pascal.
Boolean Data Type in Pascal
In essence, Boolean values are integer types. Boolean variables have two pre-defined values: True and False. Boolean expressions can also be assigned to a Boolean type.
Free Pascal also supports ByteBool, WordBool, and LongBool types corresponding to Byte, Word, and Longint types.
The value False is equivalent to 0 (zero), and values not considered True when converted to Boolean. The True value of Boolean is converted to 1 when assigned to a LongBool variable.
Note: Logical operators and, or, and not are not defined for the Boolean data type in Pascal.
Declaration of Boolean Data Type in Pascal
Variables of Boolean data type in Pascal are declared using the var keyword:
var
boolean-identifier: boolean;
Example:
var
choice: boolean;
Example
Here is an example of declaring a Boolean data type:
When the above code is compiled and executed, it will return the following result:
In the Mytour article above, we introduced you to the Boolean data type in Pascal. Additionally, you can explore more in the article Data Types in Pascal to have a deeper understanding of this programming language. The next Mytour article will continue the discussion on arrays in Pascal. Don't forget to stay tuned for new articles on Mytour!
