High-level Programming Language (Pascal)
Boolean Expressions
¡@var Found : Boolean;
which declares that Found is a Boolean variable
Boolean_variable := Boolean_expression
¡@Female := true;
which assigns the Boolean constant true to the Boolean variable Femal
|
Pascal
Operator
(Arithmetic, Relational, Boolean) |
Order
of Precedence
|
|
(
) (parentheses)
|
1 highest (performed first) |
|
-
(unary operator) , not
|
2 |
|
*
, / , div , mod , and
|
3 |
|
+
, - , or
|
4 |
|
=
, <> , > , >= , < , <=
|
5 lowest (performed last) |
<expression_1> <relational operator> <expression_2>
|
Mathematical
Relational Operator
|
Pascal
Relational Operator
|
Meaning
|
|
=
|
=
|
equal to |
|
¡Ú
|
<>
|
not equal to |
|
>
|
>
|
greater than |
|
¡Ù
|
>=
|
greater than or equal to |
|
<
|
<
|
less than |
|
¡Ø
|
<=
|
less than or equal to |
|
Score
|
PassMark
|
|
49
|
50
|
|
Boolean
Expression
|
Meaning
|
Result
|
Reason
|
|
5
> 1
|
5 is greater than 1 |
true
|
5 is greater 1 is true |
|
'A'
< 'F'
|
character 'A' is less than character 'F' |
true
|
the ASCII code of 'A' (65) which is less than the ASCII code of F (70) |
|
'12345'
> '200'
|
character '12345' is greater than character '200' |
false
|
the ASCII code of the first character of '12345' is not greater than the ASCII code of the first character of '200' |
|
12345
> 200
|
12345 is greater than 200 |
true
|
|
|
'4A'
> '4'
|
character '4A' is greater than character '4' |
true
|
|
|
3*2
> 1+7
|
3 times 2 is greater than 1 plus 7 |
false
|
3 times 2 (i.e. 6) is not greater than 1 plus 7 (i.e. 8) |
|
Score
< PassMark
|
Score is less than PassMark |
true
|
Score (49) is less than PassMark (50) is true |
|
A
|
B
|
A
and B
|
A
or B
|
not
A
|
|
true
|
true
|
true
|
true
|
false
|
|
true
|
false
|
false
|
true
|
false
|
|
false
|
true
|
false
|
true
|
true
|
|
false
|
false
|
false
|
false
|
true
|