330 Programming
2. Run the program to display the volume of a cylinder with a height of
34 mm and a radius of 5 mm.
Note: You do not have to use the parameter names when you run the
volcyl program, but you must supply two arguments (as values, variables,
or expressions). The first must represent the height, and the second must
represent the radius.
Displaying information
A running function or program does not display intermediate calculated
results unless you include a Disp command. This is an important
difference between performing a calculation on the entry line and
performing it in a function or program.
These calculations do not display a result in a function or program
(although they do from the entry line).
Disp displays calculation result or text in a function or program.
Displaying a result does not store that result. If you expect to refer later
to a result calculated in a program, store the result to a global variable.
Using local variables
A local variable is a temporary variable that exists only while a user-
defined function is being evaluated or a user-defined program is
running.
Example of a local variable
The following program segment shows a For...EndFor loop (which is
discussed later in this module). The variable i is the loop counter. In most
cases, the variable
i is used only while the program is running.
volcyl(34,5) Volume = 534.071
12¦6
cos(
p/4)
Disp 12¦6
Disp “Result:”,cos(
p/4)
cos(p/4)&maximum
Disp maximum