Program:

Comments:

 

 

«

 

→ a b

Creates local variables a and b.

'π^2*(b^2-a^2)'

Calculates the surface area.

→NUM

Converts algebraic to a number.

»

 

 

 

`

Puts the program on the stack.

OTORSA K

Stores the program in TORSA.

 

 

Here is a stack diagram and program listing for TORSV.

Level 2

Level 1

Level 1

 

 

 

 

 

a

b

volume

 

 

 

 

 

 

 

 

 

 

Program:

 

 

Comments:

 

 

 

 

 

 

«

 

 

 

 

→ a b

 

 

Creates local variables a and b.

«

 

 

Starts a program as the defining

 

 

 

procedure.

 

a b TORSA

 

 

Puts the numbers stored in a and b

 

 

 

on the stack, then calls TORSA

 

 

 

with those arguments.

 

b a - * 4 /

 

Completes the volume calculation

 

 

 

using the surface area.

 

»

 

 

Ends the defining procedure.

»

 

 

 

 

 

 

 

 

`

 

 

Puts the program on the stack.

OTORSV K

 

 

Stores the program in TORSV.

 

 

 

 

 

Now use TORSV to calculate the volume of a torus of inner radius a = 6 and outer radius b = 8.

6 `8 J%TORSV%

1-30 RPL Programming