Looping Qbasic Chapter 5
Looping Qbasic Chapter 5
WHILE <condition>
<instruction-list>
WEND
where,
condition is a logical expression
instruction-list is the set of instructions to be executed repeatedly.
Steps Of Execution-
1. condition is evaluated.
2. If condition evaluates to true, instruction-list is executed, otherwise the control
is transferred to instructions immediately after WEND.
3.The WEND statement transfers the control back to step 1.
Example-1
Using the loop in a programme-
CLS
X=10
WHILE X<15
PRINT "The value of X is:"; X
X=X+1
WEND
END
WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100 PRINT SERIES -5,-4,-3,-2,-1, 0, 1, 2,3,4,5
CLS CLS
A=1 A=-5
WHILE A<=10
PRINT A
B=1
A=A+2 WHILE B<=10
WEND PRINT A
END A=A+1
B=B+1
Print the series 1,4,9,16,25 WEND
CLS END
A=1
WHILE A<=5
100, 98.5, 97, 95.5….10TH TERM
PRINT A*A
A=A+1 CLS
WEND A=100
END B=1
WHILE B<=10
PRINT A
A=A-1.5
B=B+1
WEND
END