0% found this document useful (0 votes)
6 views3 pages

While Loop Qbasic

The document provides an overview of QBASIC programming, focusing on while loops, including both finite and infinite loops. It includes example programs for calculating the sum of even and odd numbers, the sum of digits of a number, and various tasks such as finding the maximum number from a list, counting positive and negative numbers, and checking for palindromes and Armstrong numbers. Additionally, it outlines the structure of while loops and their usage in programming.

Uploaded by

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

While Loop Qbasic

The document provides an overview of QBASIC programming, focusing on while loops, including both finite and infinite loops. It includes example programs for calculating the sum of even and odd numbers, the sum of digits of a number, and various tasks such as finding the maximum number from a list, counting positive and negative numbers, and checking for palindromes and Armstrong numbers. Additionally, it outlines the structure of while loops and their usage in programming.

Uploaded by

andysingh5599
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like