Sharp MZ-700 Series Owner's Manual page 74

Personal computer
Hide thumbs Also See for MZ-700 Series:
Table of Contents

Advertisement

Examples of use of the built-in funcions
(Example 1)
Let's try solving the various elements of a triangle with a BASIC program.
Angle A of the triangle shown in the figure at right is 30°,
angle B is a right angle, and side CA has a length of 12. The
following program finds all angles of the triangle, the
length of its sides, and its total area.
1 0
A = 3 0 : B = 9 0 : C A = 1 2
2 0
A B = C A X C O S
( A X P A I ( 1 ) 0 1 8 0 )
3 0
B C = C A X S I N ( A X P A I ( 1 ) 0 1 8 0 )
4 0
S = A B X B C 0 2
5 0
C = 1 8 0 — A — B
6 0
P R I N T
" A B = " ; A B ,
" B C = " ; B C ,
7 0
P R I N T
" A R E A S = "
; S
8 0
P R I N T
" A = "
; A ,
" B = " ; B .
" C = "
9 0
E N D
C A = 1 2
A B
C A = " ; C A
C
(Example 2)
Now let's change line 50 of the program to use ATN, the function for finding the arctangent of a number,
to fine angle C from sides AB and BC.
1 0
A = 3 0 : B = 9 0 : C A = 1 2
2 0
A B = C A X C O S
( A X P A I ( 1 ) 0 1 8 0 )
3 0
B C = C A X S I N ( A X P A I ( 1 ) 0 1 8 0 )
4 0
S = A B X B C 0 2
5 0
C = A T N ( A B 0 B C ) X 1 8 0 0 P A I ( 1 )
6 0
P R I N T
" A B = " ; A B ,
|:
B C = " ; B C ,
7 0
P R I N T
" A R E A S = " ; S
8 0
P R I N T
" A— " ; A ,
" B = " ; B ,
" C = "
9 0
E N D
C A = " ; C A
; C
RND function
Format
RND (X)
X . . Numeric expression
Function
The RND function returns a pseudo-random number in the range from 0.00000001
to 0.99999999.
When X is greater than 0, the random number returned is the one which follows that
previously generated by the BASIC interpreter in a given pseudo-random number
series.
When X
0, the BASIC Interpreter's pseudo-random number generator is reinitia-
lized to start a new series, and the pseudo-random number returned is the first one
in that series. Reinitialization of the pseudo-random number series in this manner
can be used to allow simulations based on random numbers to be reproduced.
72-

Advertisement

Table of Contents
loading

Table of Contents