beautypg.com

Slope :normal y=m¡x+5 _ slope :normal m – Sharp EL-5230 User Manual

Page 79

background image

77

Chapter 7: Programming

Use of variables

Global and local variables are treated differently in the PROG mode.

• The letters A – Z and θ, used on their own, represent global variables.

Global variables correspond to the memories of the calculator (e.g., ‘C’ in a
program means memory C of the calculator). Global variables allow your
programs to use values stored in memories, or to pass variables from one
program to another. Global variables also allow you to store results from
programs and use them in any mode.

• You can also name and use up to nine local variables (@ v). Local

variables retain values only in an individual program.

If a line in your program contains an equation
such as Y = M

1

X + 5, it sets the global variable

Y equal to (M

1

× X) + 5. On encountering this

equation while running the program, if the
value of the local variable M

1

has not been

defined earlier in the program, the calculator
prompts you with the display ‘M

1

=?’ to enter a

value for M

1

. The global variable X will already

be set to the value last stored in that memory.

With just a little practice you will soon become
proficient at typing programs into your calculator.

Example

Create a simple program that requests input of the base length (B

1

)

and height (H

1

) of a triangle and then calculates the area (A). After

creating, RUN the program to determine the area of a triangle with a
base of 4 units and a height of 3 units.

1.

Preparing to create a NEW program

SLOPE :NORMAL
Y=M¡X+5

_

SLOPE :NORMAL
M¡=?

Enter the PROG mode.

b 2

Select NEW.

Procedure

Key operations

Display

1

Select the NORMAL program mode.

0

e

Type the program name.

AREA

Enter the program name.

AREA :NORMAL
PROGRAM?

This manual is related to the following products: