Basic Program Configuration; Basic Program Format - Casio FX-890P Owner's Manual

Casio personal computer owner's manual
Table of Contents

Advertisement

5.2 BASIC Program Configuration

5.2.1 BASIC Program Format

The following is a typical BASIC program, which calculates the volume of a cylinder.
EXAMPLE:
10 REM CYLINDER
20 R=15
30 INPUT "H=";H
40 V=PI*R^2*H
50 PRINT "V=";V
60 END
As can be seen, the BASIC program is actually a collection of lines (six lines in the
above program). A line can be broken down into a line number and a statement.
20 R=15
Line Statement
number
Computers execute programs in the order of their line numbers. In the sample
program listed above, the execution sequence is 10, 20, 30, 40, 50, 60. Program
lines can be input into the computer in any sequence, and the computer
automatically arranges the program within its memory in order from the smallest line
number to the highest. Lines can be numbered using any value from 1 to 65535.
20 R=15
40 V=PI*R^2*H
60 END
10 REM CYLINDER
30 INPUT "H=";H
50 PRINT "V=";V
Input sequence
Following the line number is a statement or statements which actually tell the
computer which operation to perform. The following returns to the sample program to
explain each statement in detail
10 REM CYLINDER
20 R=15
30 INPUT "H=";H
40 V=PI*R^2*H
50 PRINT "V=";V
60 END
As can be seen, a mere six lines of programming handles quite a bit of data. Multiple
BASIC program lines can also be linked into a single line using colons.
EXAMPLE:
100 R==15:A=7:B=8
Such a program line is known as "multi-statement".
REM stands for "remark". Nothing in this line is executed.
Assigns the constant 15 (radius) to variable R.
Displays H= to prompt a value input for height.
Calculates volume (V) of cylinder.
Prints result of line 40
Ends program.
27
10 REM CYLINDER
20 R=15
30 INPUT "H=";H
40 V=PI*R^2*H
50 PRINT "V=";V
60 END
Memory contents

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents