Page 111 - TechPluse_C7_Flipbook
P. 111
Program 8: To print square of numbers from 1 to 5
Infinite Loop
A loop which never ends is called infinite loop. You should avoid such conditions while
programming. If a while loop condition does not become false, the loop runs for ever, creating
an infinite loop.
Example 1:
number = 1
WHILE (number < 10)
PRINT number
END WHILE
The above program will never end as the value of number is always 1, which is less than 10. So,
the loop will execute infinite times.
Example 2:
WHILE (True)
PRINT "Loop Never Ends"
END WHILE
In the above program, the condition True always remains true, so the loop will never stop. This
results in an infinite loop, continuously printing Loop Never Ends.
Tech
Funda
Once the loop reaches its end, you use the keyword END WHILE to signal that
the while loop will end. That way the loop does not continue forever, creating
an infinite loop.
Conditional and Looping Statements in BASIC-256 109

