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”

/initializing C=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”

/stores the value of N+S into S thus sums the count down numbers.

/stores the value of N+1 into N thus changes the count down number.

/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

ENTER A NUMBER **8**

8

9

10

SUM=

27

COUNT= 3