1
(However, FOR loops do not need to always count upward by one.)
Here is a diagram that shows how the COUNT changes as the program runs:
' Counting Loop---using a FOR ' ' values of COUNT changing over time ---> ' FOR COUNT = 0 TO 2 0 1 2 3 PRINT COUNT 0 1 2 NEXT COUNT 1 2 3 END
COUNT starts out at 0, stays 0 for the PRINT statement, then changes to 1
at the NEXT COUNT statement.COUNT is 1, it stays 1 for the PRINT statement, then changes to
2 at the NEXT COUNT statement.COUNT is 2, it stays 2 for the PRINT statement,
then changes to 3 at the NEXT COUNT statement.What does the following program print?
' Counting Loop FOR COUNT = 1 TO 4 PRINT COUNT NEXT COUNT END