# Boolean variable type in Pascal

In this article, we'll look at the Pascal boolean variable type. This type of variable is very important to know, as it is the basis of the Pascal language, and not only it.

To begin with, it is worth saying that this variable has only two values: true or false. When a variable with this type is equated with "yes" - true, then the computer sees such a result as one, but if the value of "no" is false, then it takes it as zero.

This type has its own four logical operations:

- and
- or
- xor
- not

Now let's analyze each operation separately.

## And

Operation and. In this operation, the expression will be true if all values are true. Let's confirm in practice:

In this case, the user enters two numbers, if they are divided by two without residue, then the expression is true. But if at least one number is odd, then the expression will be false.

## Or

Operation or. In this operation, an expression will be true if at least one value is true. Example:

In this case, the user enters two numbers, if at least one number is divided by two without a remainder, then the whole expression is true. An expression will only be false if both numbers are false.

## Not

Operation not. In this operation, the expression will be true if the value satisfies the conditions.

Example:

In this case, the user enters one number, if this number leaves zero in the remainder when divided by two, then this expression is false. If the user enters an odd number, then the expression is true. This is how it works, because the conditions are preceded by the prefix not.

## Xor

The xor operation. In this operation, an expression will be true if at least one expression is true. This operation works the same way or works, but unlike it, an expression can be false when two values are true - this is the main difference from or.

In this case, the user enters two numbers, if one of these numbers is even, then the expression will be true. If the user enters odd two numbers, the expression is false, or if the user enters two even numbers, the expression will also be false.

That's it. As you can see, there is nothing complicated in the operations of this data. The type itself is very useful. It is very convenient to use in cycles or algorithms to check the conditions.

## Total

Boolean has four operations: or, not, and, xor. Each of these operations "differently" accepts the truth:

- Or. an expression will be true if at least one meaning is true. An expression will only be false if all expressions are false.
- Not. an expression will be true if it fulfills the conditions set. The expression will be false only if the condition is not met.
- And. An expression will be true if both meanings are true. An expression is false if at least one of the meanings is false.
- Xor. An expression will be true if only one of the meanings is true. But if there are two true meanings or there are none at all, then the expression is false.

Programming languages are very similar to each other, so having studied the type of boolean in pascal, consider that you have studied them in many other languages. This is an important and necessary type of variable that every encoder should be aware of.

That's it! Thank you very much for your attention and interesting projects. Good luck!