The Case Construct - HP 49g+ User Manual

Graphing calculator
Hide thumbs Also See for 49g+:
Table of Contents

Advertisement

→ x
IF 'x<3' THEN 'x^2' ELSE IF 'x<5' THEN '1-x' ELSE IF
«
«
'x<3*π' THEN 'SIN(x)' ELSE IF 'x<15' THEN 'EXP(x)' ELSE –2
END END END END EVAL » »
Store the program in variable @@@f3@@@ and try the following evaluations:
1.5 @@f3@@@
2.5 @@@f3@@@
4.2 @@@f3@@@
5.6 @@@f3@@@
12 @@@f3@@@
23 @@@f3@@@

The CASE construct

The CASE construct can be used to code several possible program flux paths,
as in the case of the nested IF constructs presented earlier. The general
format of this construct is as follows:
CASE
Logical_statement
Logical_statement
.
.
.
Logical_statement THEN program_statements END
Default_program_statements (optional)
END
When evaluating this construct, the program tests each of the
logical_statements until it finds one that is true. The program executes the
corresponding program_statements, and passes program flow to the statement
following the END statement.
The CASE, THEN, and END statements are available for selective typing by
using „°@) @ BRCH@ @) C ASE@ .
2
Result: 2.25 (i.e., x
)
2
Result: 6.25 (i.e., x
)
Result: -3.2 (i.e., 1-x)
Result: -0.631266... (i.e., sin(x), with x in radians)
Result: 162754.791419 (i.e., exp(x))
Result: -2. (i.e., -2)
THEN program_statements
1
THEN program_statements
2
END
1
END
2
Page 21-51

Advertisement

Table of Contents
loading

Table of Contents