1/5
QB64 - Programming statements
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Loop/Iteration
process of repetition in programming
For...Next
to perform a loop specific no. of times
uses a counter variable jo is increased or decreased
Syntax:
For counter variable = Start Value To End Value Step
Print whatever
Next counter variable
For = beginning of loop
StartValue = actual value of variable
EndValue= value the variable shd reach to end the loop
StepValue = amount by which the variable changes after each loop
Next = ends the loop
DO WHILE… LOOP
performed as long as the given statement is true
Before the loop is ended, counter variable shd be increased/decreased
When step value is missing, it becomes an infinite loop!
Syntax Example
assign value to variable. a = 1
Do while test condition Do while a<=10
Statement 1 print a
Statement 2 a = a+1
Loop Loop
DO UNTIL…LOOP
executed until a certain condition is met
If,
statement false = executed
statement true = stops executing
Syntax
DO UNTIL test condtion
Statement 1
Statement 2
LOOP
WHILE…WEND
executes a series of statements until the condition is true
Syntax
WHILE test condition
Statements
WEND
EXIT
Used to come out of a loop before the expected no. of times
Generally followed by IF