If-then-else, If-then-else if-then-else 8, 1, 2, and 3 – Texas Instruments TI-73 EXPLORER User Manual
Page 236
230
Chapter 12: Programming
7312ENG.DOC CH 12 Programming, English Julie Hewlett Revised: 07/29/98 12:17 PM Printed: 05/19/99 9:02
AM Page 230 of 32
Write a program named
TEST
that tests the values of variable
X. If X<10, manipulate X and Y and then display both values. If
X10, then display X and Y (without manipulating them).
PROGRAM:TEST
:1"X:10"Y
:If X<10
:Then
:2X+3"X
:2Y-3"Y
:End
:Disp {X,Y}
:Pause
If-Then-Else
If-Then-Else 8
1, 2, and 3
1, 2, and 3
Use
If
with
Then
and
Else
to execute only one of two blocks of
commands depending upon condition. If condition is true
(non-zero), then block1 is executed. If condition is false
(zero), then block2 is executed.
End
identifies the end of
block2.
Then
,
Else
, and
End
each must be on a line by itself.
:
If
condition
:
Then
:block1 (if true)
:
Else
:block2 (if false)
:
End
:command
³