Texas Instruments TINSPIRE Manual Book page 710

Teacher software guidebook
Hide thumbs Also See for TINSPIRE:
Table of Contents

Advertisement

For i,0,5,1
Disp i
À
EndFor
Disp i
Á
À
Displays 0, 1, 2, 3, 4, and 5.
Á
Displays 6. When variable increments to 6, the loop is not executed.
Note: You can declare the counter variable as local if it does not need to
be saved after the function or program stops.
While...EndWhile loops
A
While...EndWhile
specified condition is true. The syntax of the
condition
While
is executed, condition is evaluated. If condition is true, the
When
While
loop is executed; otherwise, control jumps to the command following
.
EndWhile
x < 5
|
x
5
Note: The
While
You must include commands that allow the function or program to exit
the loop.
At the end of the loop (
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
command. (You can build the values into the function or
While
program, or you can 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 function or program cannot exit the loop
(called an infinite loop).
For example:
698
Programming
loop repeats a block of commands as long as a
While x<5
--------
--------
EndWhile
--------
command does not automatically change the condition.
EndWhile
While
), control jumps back to the
command is:
While

Advertisement

Table of Contents
loading

Table of Contents