Anatomy of a Program

You might recognize this program as being an expanded version of the one which appears on page 31 of your T/S 1000 User Manual.

Statements 10 through 30 are simple print commands.

Statement 40 is much more complex. In this statement, we are telling the computer to randomly (RND) select a number (INT; an integer) between 1 and 100 and to store it in a location we shall call A (LET A =). Now, since the computer produces an (integer) fractional number (less than 1), we multiply that integer by 100 (RND*100). And since we want a universe of 100 numbers, we then add 1 to the random command (RND*100) + 1.

Statement 50 tells the computer that we will input certain data (a number) and we want the computer to store this input at a location we shall call B.

Statement 60 is a yes/no compare statement. We are telling the computer that if the number the computer has stored in location A is less than the number stored in location B, proceed to carry out the instruction stated in Statement 90; otherwise, go to the next statement (70).

Statement 70 is the reverse of Statement 60; if the number the computer has stored in location A is greater than the number stored in location B, the computer is to carry out the instruction listed in Statement 110; otherwise, proceed to Statement 80.

Statement 80 asks the computer to compare the numbers stored in locations A and B, and if they are equal, carry out the instructions specified in Statement 130.

Statements 90, 110, and 130 are simple print commands. Note that the (;B) tells the computer to also print the number that was input at the keyboard.

Statements 100 and 120 are also compare statements. In effect, they tell the computer that since the number we input was either too high or too low, we will input another number — to try again (at Statement 50).

Tags