Rules for AND
OR
In everyday life the word 'or' is used in two ways. We can illustrate the inclusive use of OR by thinking
of a cricket captain looking for players. He might ask "Can you bat or bowl?" He would be pleased if a
player could do just one thing well but he would also be pleased if someone could do both. So it is in
programming: a compound expression using OR is true if either or both of the simple statements or
variables are true. Try the following program.
100 REMark OR test
110 PRINT "Enter two values" \ "1 for TRUE or 0 for FALSE"
120 INPUT "Can you bat?", batsman
130 INPUT "Can you bowl?", bowler
140 IF batsman OR bowler THEN PRINT "In the team"
You can see the effects of different combinations of answers in the rules below:
Rules for OR
When the inclusive OR is used a true value in either of the simple statements will produce a true
value in the compound expression. If Ian Botham, the England all rounder were to answer the
questions both as a bowler and as a batsman, both simple statements would be true and so would the
compound expression. He would be in the team.
If you write 0 for false and 1 for true you will get all the possible combinations by counting in binary
numbers:
00
01
10
11
NOT
The word NOT has the obvious meaning.
NOT true is the same as false
NOT false is the same as true
However you need to be careful. Suppose you hold a red triangle and say that it is:
NOT red AND square
In English this may be ambiguous.
If you mean:
(NOT red) AND square
then for a red triangle the expression is false.
If you mean: