EasyManua.ls Logo

Husky Hunter - Page 122

Husky Hunter
499 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
BASIC PROGRAMMING
SECTION 4 .• 2
VER.V09F
Logical operations may also be used by conditional statements,
for example:
IF A=B AND B=C THEN PRINT"ALL EQUAL"
In this example the following occurs:
1) The variables A,B are tested for equality. If they are equal
then a true (-1) condition is returned,
if not then a false (0)
is returned.
2) The variables B,C are tested for equality. The results are
as in
(1) above.
3) The logical operation AND is then performed on the results of
(1) and (2) above, which returns either a true (-1) or false (0)
result. It is this final result upon which the IF statement
performs its conditional test (true or false). Since
conditional statements always produce a logical result it is
possible in some circumstances· to omit a relational operator,
for example:
IF A<>O THEN PRINI'"A IS NON ZERO"
may be replaced with:
I!"' A THEN PRINT"A IS NON ZERO"
or
IF A=5 THEN PRINT -1 ELSE PRINT 0
may be replaced with:
PRINT A=5
since A and 5 are tested for equality and if they are equal the
-1 (true) is printed otherwise O (false) is printed.
PAGE 4 - 7