QBASIC PROGRAMMING
While Loop
The while loop is an example of entry level looping statement. It means
the condition is at the first line of the loop. The expressions executed
until the condition returns true.
Finite state
Initilization
While condition
Expressions
Increment/decrement
Wend
Q WAP that accept 10 numbers find out the sum of even and odd
numbers separately?
Cls
I=1
E=0
Od=0
Print “Enter 10 numbers”
While i<=10
Input num
If num mod 2 =0 then
E=e+num
Else
Od=od+num
PROF JITENDRA KUMAR SINHA 1
QBASIC PROGRAMMING
End if
I=i+1
Wend
Print “Even sum=”,e
Print “Odd sum=”,od
Infinite loop
The loop in which the number of iterations is not earlier decided then
it is known as infinite loop. One of the most probable conditions is that
the iteration is up to the value is greater than 0.
While condition
Expressions
Wend
Q WAP that accept any number find out the sum of their digits?
Cls
S=0
Input “Enter the number:” ,num
While num > 0
D=num mod 10
Num=num \10
S=s+d
PROF JITENDRA KUMAR SINHA 2
QBASIC PROGRAMMING
Wend
Print “Sum of digits=”, s
Q1 WAP that accept 10 numbers find out the maximum from the given
list of numbers?
Q2 WAP that accept 10 numbers count how many of them are +ve, -
ve or zero?
Q3 WAP that accept any number show their table?
Q4 WAP that accept any number then check it is palindrome number
or not? (121)
Q5 WAP that accept any number then check it is armstrom number or
not?(153)
PROF JITENDRA KUMAR SINHA 3