Write a program to display a word 10 times in Qbasic.
Answers
Question:-
Write a program in QBASIC to display a word 10 times.
Program:-
CLS
INPUT "ENTER A WORD ";N$
FOR I=1 TO 10 STEP 1
PRINT N$
NEXT I
END
Input the word. The word will printed 10 times.
Answer:
1 - Declare your variable before the loop
2 - Set the loop using the letter “i” instead of your variable. I don’t know how it works, but the program understands that “i” is your variable.
3 - Set the “start” part to i = 0, since we want the loop to begin from the very first time that the variable is printed.
4 - Set the “stop” part to i <= 10, since we want it to stop at the tenth repetition.
5 - Set the last part to “i = i + 1”, by doing so, the program adds a “counter” to your variable each times it does a loop, so it will know when to stop working. Note: you can use “i++” instead of “i = i + 1”, it’s the same thing.
Explanation: