May 12, 2013

WHILE...WEND loop

The WHILE...WEND loop executes a set of instructions as long as a given condition is true.The syntax of the WHILE...WEND loop is given below:

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

Try this in your qbasic and explore more.......

1 comment: