EasyManua.ls Logo

Sinclair QL - Page 62

Sinclair QL
135 pages
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...
Basically numeric expressions in SuperBASIC are the same as those of mathematics but you must
put the whole expression in the form of a sequence.
5+3
6-4
becomes in SuperBASIC (or other BASIC):
(5 + 3)/(6 - 4)
In secondary school algebra there is an expression for one solution of a quadratic equation:
ax
2
+ bx + c = 0
One solution in mathematical notation is:
If we start with the equation:
2x
2
- 3x + 1 = 0
Example 1
The following program will find one solution.
100 READ a,b,c
110 PRINT 'Root is' ! (-b+SQRT(b^2 - 4*a*c))/(2*a)
120 DATA 2,-3,1
Example 2
In problems which need to simulate the dealing of cards you can make cards correspond to the
numbers 1 to 52 as follows:
1 to 13
14 to 26
27 to 39
40 to 52
Ace, two........king of hearts
Ace, two........king of clubs
Ace, two........king of diamonds
Ace, two........king of spades
A particular card can be identified as follows:
100 REM Card identification
110 LET card = 23
120 LET suit = (card-1) DIV 13
130 LET value = card MOD 13
140 IF value = 0 THEN LET value = 13
150 IF value = 1 THEN PRINT "Ace of ";
160 IF value >= 2 AND value <= 10 THEN PRINT value ! "of ";
170 IF value = 11 THEN PRINT "Jack of ";
180 IF value = 12 THEN PRINT "Queen of ";
190 IF value = 13 THEN PRINT "King of ";
200 IF suit = 0 THEN PRINT "hearts"

Other manuals for Sinclair QL

Related product manuals