Zero.
It is perfectly OK to ask a program to do something zero times. This is like asking your car's windshield wipers to wipe the windshield zero times on a sunny day.
Here is how the zero repetitions come about.
The number 0 will be stored in ENDVALUE
:
PRINT "How many times do you want to print Hello" INPUT ENDVALUE
Now COUNT
will start out at 1:
LET COUNT = 1
Now the DO WHILE
statement acts like a gatekeeper
to see if execution is allowed to enter the loop body:
DO WHILE COUNT <= ENDVALUE
The contents of COUNT
is compared
to the contents of ENDVALUE
.
This is like replacing the variables with the values inside of them:
DO WHILE 1 <= 0
1 <= 0
is false, so execution does not enter the loop,
and the next statement after the LOOP
is executed: END
.
The program stops, as it should.
What would happen if the user typed in -10 for the number of times to execute the loop?