How to count backwards in QBasic?
In QBasic, you can use a "FOR" loop to count backwards. Here's an example of how you might use a "FOR" loop to count backwards from 10 to 1:
FOR i = 10 TO 1 STEP -1
PRINT i
NEXT i
In this example, the variable "i" is the loop variable and is set to the initial value of 10. The "TO" keyword specifies the final value of the loop variable, which is 1 in this case. The "STEP -1" keyword specifies that the loop variable should be decremented by 1 on each iteration of the loop. The "PRINT i" line inside the loop will be executed repeatedly, and each time the value of "i" will be decremented by 1, until the loop variable reaches the final value of 1.
So, this program will output the values of 10,9,8,7,6,5,4,3,2,1
0 Comments