Sam Powell - ti 83/84 programs - Math/Computer Teacher - Northridge H.S. - Middlebury Indiana |Programming Page |TI 83/84 Programs |mrpowell.net |

TI 83/84 - Pre test Loop


Purpose : This program will illustrate a pre test loop. The loop was designed to count down to 10. It will count each pass through the loop and display the final count. It will also output the count down numbers and their sum. If the number entered is less than ten, then there will be no passes through the loop and the count and sum will both be zero. Use this type of loop when you don’t know precisely how many times you will pass through the loop and you do not know if you will automatically pass through at least one time.

ClrHome
Input “ENTER A NUMBER”,N        /Outputting prompt and inputting data stored in “N”
c=0                                              /initializing C=0
s=0                                               /initializing S=0
While N < 10                         /Begin loop (remains active until While N<10 is false)
Disp N                                              /Displays the value stored in the variable “N”
n+s=s                             /stores the value of N+S into S thus sums the count down numbers.
n+1=n                              /stores the value of N+1 into N thus changes the count down number.
c+1=c                                 /stores the value of C+1 into C thus counts the passes through the loop.
Pause                                                /Pause program until “ENTER” is pressed
END                                                 /End of Loop
Disp “SUM=”,S                                /Outputs the string “SUM=” and the value stored in S
Disp “COUNT”,C                             /Outputs “COUNT=” and the value stored in C

Output

ENTER A NUMBER 8
                       
                                    8
                                    9
                                 10
SUM=
                                 27
COUNT=                   3