EasyManuals Logo

Texas Instruments TI-89 Guide Book

Texas Instruments TI-89
623 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #315 background imageLoading...
Page #315 background image
298 Chapter 17: Programming
17PROGRM.DOC TI-89/TI-92 Plus: Programming (English) Susan Gullord Revised: 02/23/01 1:14 PM Printed: 02/23/01 2:18 PM Page 298 of 40
For example:
:For i,0,5,1
: Disp i
:EndFor
:Disp i
A
While...EndWhile
loop repeats a block of commands as long as a
specified condition is true. The syntax of the
While
command is:
While
condition
When
While
is executed, the condition is evaluated. If
condition
is
true, the loop is executed; otherwise, program control jumps to the
command following
EndWhile
.
:While x<5
: --------
: --------
:EndWhile
:--------
At the end of the loop (
EndWhile
), program control jumps back to
the
While
command, where
condition
is re-evaluated.
To execute the loop the first time, the
condition
must initially be
true.
¦ Any variables referenced in the
condition
must be set before the
While
command. (You can build the values into the program or
prompt the user to enter the values.)
¦ The loop must contain commands that change the values in the
condition
, eventually causing it to be false. Otherwise, the
condition
is always true and the program cannot exit the loop
(called an infinite loop).
For example:
:0
!
x
:While x<5
: Disp x
: x+1
!
x
:EndWhile
:Disp x
Tip:
You can declare the
counter variable as local
(pages 288 and 290) if it
does not need to be saved
after the program stops.
While...EndWhile
Loops
Note:
The
While
command
does not automatically
change the condition. You
must include commands
that allow the program to
exit the loop.
Displays 0, 1, 2, 3, 4, and 5.
Displays 6. When
variable
increments to 6, the loop
is not executed.
Initially sets x.
Displays 0, 1, 2, 3, and 4.
Increments x.
Displays 5. When x
increments to 5, the loop is
not executed.
x < 5x
‚
5

Table of Contents

Other manuals for Texas Instruments TI-89

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-89 and is the answer not in the manual?

Texas Instruments TI-89 Specifications

General IconGeneral
Display size (HxV)100 x 160 mm
Memory type639K FLASH ROM, 188K bytes RAM
Compatible operating systemsOperating System 2.09
Battery typeAAA

Related product manuals