Sinclair QL Beginner's Manual page 68

Hide thumbs Also See for QL:
Table of Contents

Advertisement

PRIORITIES
The order of priority for the logical operators is (highest first):
For example the expression
means the same as:
The AND operation is performed first. To prove that the two logical expressions have identical effects
run the following program:
100 REMark Priorities
110 PRINT "Enter three values"\"Type 1 for Yes and 0 for No"!
120 INPUT rich,tall,fair
130 IF rich OR tall AND fair THEN PRINT "YES"
140 IF rich OR (tall AND fair) THEN PRINT "AYE"
Whatever combination of three zeroes or ones you input at line 120 the output will be either nothing
or:
YES
AYE
You can make sure that you test all possibilities by entering data which forms eight three digit binary
numbers 000 to 111
000 001 010 011 100 101 110 111
PROBLEMS ON CHAPTER 10
1.
Place ten numbers in a DATA statement. READ each number and if it is greater than 20 then
print it.
2.
Test all the numbers from 1 to 100 and print only those which are perfect squares or divisible
by 7
3.
Toys are described as Safe (S), or Unsafe (U), Expensive (E) or Cheap (C), and either for
Girls (G),Boys (B) or Anyone (A). A trio of letters encodes the qualities of each toy. Place five
such trios in a DATA statement and then search it printing only those which are safe and
suitable for girls.
4.
Modify program 3 to print those which are expensive and not safe.
5.
Modify program 3 to print those which are safe, not expensive and suitable for anyone.
rules for XOR
NOT
AND
OR,XOR
rich OR tall AND fair
rich OR (tall AND fair)

Advertisement

Table of Contents
loading

Table of Contents