
Looping and branching
This section introduces the use of conditional branching and looping
within a program. Conditional structures evaluate 0 as false, and any other
value as true.
Comparison functions
The HP 49G provides comparison functions that you can use in
conjimction with the conditional and looping structures. You access them
from the Programming Test menu. For example, to test A in relation to B,
use the following;
A==B Returns true if A equals B.
AAB Retiuns true if A does not equal B.
A<B Returns true if A is less than B.
A>B Returns true if A is greater than B.
A<B Returns true if A is less than or equal to B.
A>B Returns true if A is greater than or equal to B.
SAME (A, B) Returns true if A is exactly the same object as B.
Conditional and looping structures
The following conditional and looping commands are available:
• IF comparison THEN code END
If comparison evaluates to true, that is a non-zero value, runs code.
• IF comparison THEN code-1 ELSE code-2 END
If comparison evaluates to true, runs code-1. If comparison evaluates
to false, code-2 is run.
• CASE expression-1 THEN code-1 END
expression-2 THEN code-2 END
expression-n THEN code-n END
END
Rims the code that corresponds to the first expression in the structure
that evaluates to true.
Introduction to programming
Page 10-13
Commentaires sur ces manuels