Jump to content

TI-Basic 84 Programming/Loops

From Wikibooks, open books for an open world

For, PRGM:CTL:4 is command used to perform a specific block of code a set number of times.

Syntax: For

[edit | edit source]
:For(variable,starting number,stopping number,increment)
://code
://code
:End
  • Variable is some numeric variable (Ex: X). Starting number is the variable will be set as in the beginning. Stopping number is the final number that the variable will be. Increment is the amount variable will go up or down after each run-through the loop; increment has a default of 1 and can be left off.

Ex: For

[edit | edit source]

First Example

[edit | edit source]
PROGRAM:TEMP
For(X,0,3,1)
Disp X
End
prgmTEMP
           0
           1
           2
           3


Second Example

[edit | edit source]
PROGRAM:TEMPA
For(X,3,0,-1)
Disp X
End
prgmTEMPA
           3
           2
           1
           0

While

[edit | edit source]

While, PGRM:CTL:5 is a command used to have a loop run as long as a specific condition is met.

Syntax: While

[edit | edit source]
:While condition
://code
://code
:End

Ex: While

[edit | edit source]
PROGRAM:TEMP
          0
          1
          2
          3
prgmTEMP{{{3}}}


Previous: Test Conditions and Logical Operators
Next: Picture Variables
Table of Contents: TI-Basic 84 Programming