EasyManua.ls Logo

Commodore VIC-20 - Page 127

Commodore VIC-20
404 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...
Chapter
3:
Programming the
VIC
20
Computer 113
EXP Raises the natural logarithm base e to the power
of
the argument
(ea
rg
).
LOG Returns the natural logarithm of the argument.
RND Generates a random number. There are some rules
regarding
use
of RND; they are described in
Chapter
5.
SIN Returns the trigonometric sine
of
the argument,
which
is
treated as a radian quantity.
COS Returns the trigonometric cosine of the argument,
which
is
treated as a radian quantity.
TAN Returns the trigonometric tangent of the argument,
which
is
treated as a radian quantity.
A TN Returns the trigonometric arctangent of the
argument, which
is
treated as a radian quantity.
The following example uses an arithmetic function:
10
A-2.743
20
B-INT(A)+7
30
PRINT
B
40
STOP
When you execute this program, the result displayed
is
9, since the integer
value
of
A
is
2.
As
an
exercise, change the statement on line
10
to an INPUT
statement. Change line
40
to GOTO
10.
Now you can enter a variety
of
values for A and watch the integer function
at
work. Use this program to
experiment with various functions.
Here
is
a more complex example using arithmetic functions.
10
INPUT
AlB
20
IF
LOO(A)(0
THEN
A-1/R
30
PRINT
SQR(A)*EXP(B)
40
OOTO
10
If you understand logarithms, then as an exercise change the statement on
line
20,
replacing the LOG function with arithmetic functions that perform
the same operation.
The argument of a function can be an expression; the expression itself
may contain functions.
For
example, change line
30
to the following state-
ment and rerun the program:
30
PRINT
SQR(A*EXP(B)+3)
N
ow
experiment with arithmetic functions by creating
PRINT
statements
that make complex use of arithmetic functions.

Other manuals for Commodore VIC-20

Related product manuals