0% found this document useful (0 votes)
250 views7 pages

Looping Qbasic Chapter 5

The document discusses FOR and WHILE loops in programming. It provides the syntax for a WHILE...WEND loop, which executes a set of instructions as long as a condition is true. An example uses a WHILE loop to print values of X as X is incremented from 10 to 15. Additional examples show using WHILE loops to print odd numbers from 1 to 100, various numeric series, and numbers counting down from 100 by 1.5 each time.

Uploaded by

samitavij
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
250 views7 pages

Looping Qbasic Chapter 5

The document discusses FOR and WHILE loops in programming. It provides the syntax for a WHILE...WEND loop, which executes a set of instructions as long as a condition is true. An example uses a WHILE loop to print values of X as X is incremented from 10 to 15. Additional examples show using WHILE loops to print odd numbers from 1 to 100, various numeric series, and numbers counting down from 100 by 1.5 each time.

Uploaded by

samitavij
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FOR i = 1 TO 4

PRINT "I am looping!"


NEXT i
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
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

You might also like