What would happen if the user typed in -10 for the number of times to execute the loop?
The loop would execute zero times.
Say that you wanted a program that asks the user for two numbers, adds them up, and prints the answer. Here is the program:
' Ask the user for two numbers ' Add them up, print the sum. ' PRINT "What is the first number" INPUT NUMBER1 ' PRINT "What is the second number" INPUT NUMBER2 ' LET SUM = NUMBER1 + NUMBER2 PRINT "The total is:", SUM ' END
Here is an example run of the program:
What is the first number ? 15.2 What is the second number ? 2.5 The total is: 17.7
Think about how you would write a program to add up 3 numbers. (Don't write the program unless you want to.)