Branching with if, The if…then…end construct – HP 50g Graphing Calculator User Manual

Page 694

Advertising
background image

Page 21-47

Branching with IF

In this section we presents examples using the constructs IF…THEN…END and
IF…THEN…ELSE…END.

The IF…THEN…END construct

The IF…THEN…END is the simplest of the IF program constructs. The general
format of this construct is:

IF logical_statement THEN program_statements END

.

The operation of this construct is as follows:

1. Evaluate logical_statement.
2. If logical_statement is true, perform program _statements and continue

program flow after the END statement.

3. If logical_statement is false, skip program_statements and continue

program flow after the END statement.

To type in the particles IF, THEN, ELSE, and END, use:

„°

@)@BRCH@ @)@IF@@

The functions

@@@IF@@ @@THEN @@ELSE@ @@ END@@ are available in that menu to be typed

selectively by the user. Alternatively, to produce an IF…THEN…END construct
directly on the stack, use:

„°

@)@BRCH@ „ @)@IF@@

This will create the following input in the stack:

Advertising