By Abdul Moqueet Q.1 Write a qbasic program to print hello world ? CLS
PRINT "Hello World!!!";
END
Q.2 Write a qbasic program to write your Introduction ? CLS
INPUT "what is your name"; name$
INPUT "what is your father name ?"; fathername$
INPUT "where do u live ?"; city$
INPUT "In which class do u study ?"; class$
INPUT "What is your school/college name"; college$
INPUT "what r your hobbies ?"; hobby$
CLS
PRINT "My name is "; name$
PRINT "My father name is "; fathername$
PRINT "I live at "; city$
PRINT "Im the student of "; college$; class$
PRINT "My hobbies are: "; hobby$
END
Q.3 Write a qbasic program to input two number and find their sum ? CLS
INPUT "Enter two number"; a, b
c = a + b
PRINT " Sum = "; c
END
Q.4 Write a qbasic program to input five numbers & find out the average of numbers ? CLS
INPUT "Enter five numbers "; n, n1, n2, n3, n4
avg = (n + n1 + n2 + n3 + n4) / 5
PRINT " Average = "; avg
END
Q.5 Write a qbasic program to input principal, rate, and time and find out the simple interest ? CLS
INPUT "Enter the principal"; p
INPUT " Enter the rate; r
INPUT "Enter the time; t
Si = (p*r*t) / 100
PRINT " The Simple Interest = "; si
END
Q.6 Write a qbasic program to input radius and find the area of circle and also find the circumference of circle ? CLS
INPUT "Enter the radius of circle"; r
area = (22/7) * r ^ 2
cir = 2 * (22/7) * r
PRINT " The area of circle = "; area
PRINT " The circumference of circle = "; cir
END
Q.7 Write a qbasic program to find out the area of rectangle ? CLS
INPUT "Enter the length of rectangle"; l
INPUT " Enter the breadth of rectangle "; b
a = l * b
PRINT " The area of rectangle = "; a
END
Q.8 Write a qbasic program to find the area of the triangle ? CLS
INPUT " Enter the base" ;b
INPUT " Enter the height" ;h
a = 1/2*b*h
PRINT" The area of triangle= " ;a
END
Q.9 Write a qbasic program to find the area of the square ? CLS
INPUT " Enter the length of side of a square" ; n
a = n ^ 2
PRINT" The area of square= "; a
END
Q.10 Write a qbasic program to find the lateral surface area and total surface area of a cube ? CLS
INPUT "Enter the 'a' of cube"; n
lsa = 4 * (n ^ 2)
tsa = 6 * ( n ^ 2)
PRINT " Lateral surface area of cube = "; lsa
PRINT " Total surface area of cube = "; tsa
END
Q.11 Write a qbasic program to find the volume of cuboid ? CLS
INPUT "Enter the length of cuboid"; l
INPUT " Enter the base of cuboid"; b
INPUT "Enter the height of cuboid"; h
vol = l * b * h
PRINT " The volume of cuboid = "; vol
END
Q.12 Write a qbasic program to input weight in Kg and convert it into gram, Pound, Ton ? CLS
INPUT "Enter the weight in kg"; kg
g = kg * 1000
t = kg / 1000
p = kg * 2.205
PRINT kg; " kilograms = "; g; " Grams";
PRINT kg; " kilograms = "; p; " Pounds";
PRINT kg; " kilograms = "; t; " Tons";
END
Q.13 Write a qbasic program ro enter distance in kilometers and convert it into meter and miles ? CLS
INPUT "Enter Distance into Kilometers"; km
m = km * 1000
miles = km / 1.6
PRINT km " Kilometers = "; m; " meters ";
PRINT km " kilometers = "; miles; " miles";
END
Q.14 Write a qbasic program to input two number if first number is greater than second number find out the sum of the number otherwise multiplication of number ? CLS
INPUT "Enter two number"; a,b
IF a>b THEN
s = a + b
PRINT "sum = "; s
ELSE
m = a * b
PRINT "multiply = "; m
END IF
END
Q.15 Write a qbasic program to input radius. If radius is greater than five then find out the area of circle else circumference of circle ? CLS
INPUT "Enter radius"; r
IF r > 5 THEN
a = 3.14 * r ^ 2
PRINT "Area of circle = "; a
ELSE
c = 2 * 3.14 * r
PRINT "Circumference of circle = "; c
END IF
END
Q.16 Write a qbasic program to input five numbers after that input any choice. If choice is greater than 5 & less than 10 then print addition, multiplication & average of five numbers ? CLS
INPUT "Enter five numbers"; n1, n2, n3, n4, n5
INPUT " Enter your choice"; ch
IF ch > 5 AND ch < 10 THEN
s = n1 + n2 + n3 + n4 + n5
m = n1 * n2 * n3 * n4 * n5
avg = s / 5
PRINT "sum = "; s
PRINT " multiplication = "; m
PRINT " Average = "; avg
END IF
END
Q.17 Write a qbasic program to input five numbers and print the sum of those number which are between 10 to 20 ? CLS
INPUT "Enter five numbers"; a, b, c, d, e
IF a > 10 AND a < 20 THEN
s = a + s
END IF
IF b > 10 AND b < 20 THEN
s = s + b
END IF
IF c > 10 AND c < 20 THEN
s = s + c
END IF
IF d > 10 AND d < 20 THEN
s = s + d
END IF
IF e > 10 AND e < 20 THEN
s = s + e
END IF
PRINT "sum = "; s
END
Q.18 Write a qbasic program to input five number. If first number is equal to last number, then find out the average of numbers ? CLS
INPUT "Enter five numbers"; n1, n2, n3, n4, n5
IF n1 = n5 THEN
PRINT " Average = "; (n1+n2+n3+n4+n5) / 5
END IF
END
Q.19 Write a qbasic program to input two numbers. If first number is greater than second print multiplication else print addition. Terminate the program when user want ? CLS
40 INPUT "Enter two number"; a, b
IF a > b THEN
PRINT "multiplication = "; a * b
ELSE
PRINT "sum = "; a + b
END IF
INPUT "Do you want to continue"; n$
IF n$ = "Y" OR "y" THEN
GOTO 40
ELSE
END
Q.20 Write a qbasic program to input two number find out the greatest and lowest number ? CLS
INPUT "Enter two number"; a, b
IF a > b THEN
PRINT a; "is greatest number"
PRINT b; "is lowest number"
ELSE
PRINT b; "is greatest number"
PRINT a; "is lowest number"
END IF
END
Q.21 Write a qbasic program to input two number and perform the operation as per choice:-
Choice 1 - addition
Choice 2 - multiplication
Choice 3 - subtraction
Choice 4 - division
Otherwise invalid choice. CLS
INPUT "Enter two number"; a,b
PRINT "Choice 1 - addition";
PRINT "Choice 2 - multiplication;
PRINT "Choice 3 - subtraction ";
PRINT "Choice 4 - division";
IF Ch = 1 THEN
PRINT "Addition = "; a + b
ELSE IF Ch = 2 THEN
PRINT "Multiplication = "; a * b
ELSE IF Ch = 3 THEN
PRINT "Subtraction = "; a - b
ELSE IF Ch = 4 THEN
PRINT "Division = "; a / b
ELSE
PRINT "Invalid choice";
END IF
END
Q.22 Write a qbasic program to count 1 to 10 ? CLS
PRINT "Counting 1 to 10";
FOR i = 1 TO 10
PRINT i
NEXT i
END
Q.23 Write a qbasic program to print all the even number from 1 to 100 ? CLS
FOR i = 1 TO 100
IF i MOD 2 = 0 THEN
PRINT i
END IF
NEXT i
END
Q.24 Write a qbasic program to print all the odd number from 1 to 100 ? CLS
FOR i = 1 TO 100
IF i MOD 2 = 1 THEN
PRINT i
NEXT i
END
Q.25 Write a qbasic program to input any number and print the table of the number ? CLS
INPUT "Enter any number"; n
FOR i = 1 TO 10
m = n * i
PRINT n; "x"; i; "="; m
NEXT i
END
Q.26 Write a qbasic program to input 5 no. & find out the greatest and lowest no. ? CLS
FOR i = 1 to 5
INPUT "Enter any number"; N
IF i = 1 THEN
G = N
L = N
END IF
IF N > L THEN
L = N
END IF
IF N > G THEN
G = NN
END IF
NEXT i
PRINT " Greatest no "; G
PRINT " Lowest no "; L
END
Q.27 Write a qbasic program to input number upto nth term and find out the summation of even and odd digit separately ? CLS
INPUT "Enter term"; N1
FOR i = 1 TO N1
INPUT " Enter no "; N
IF N MOD 2 = 0 THEN
S = S + N
ELSE
S1 = S1 + N
END IF
NEXT i
PRINT " Sum of even no = ": S
PRINT " Sum of odd no = "; S1
END
Q.28 Write a qbasic program to input number upto nth term and find out the greatest and lowest number ? CLS
INPUT "Enter term"; N1
FOR i = 1 TO N1
INPUT " Enter no "; N
IF i = 1 THEN
G = N
L = N
END IF
IF N > L THEN
L = N
END IF
IF N > G THEN
G = N
END IF
NEXT i
PRINT " Greatest no "; G
PRINT " Lowest no "; L
END
Q. 29 Write a qbasic program to input number upto nth term count how many numbers are greater than 100 and less than 100 ? CLS
INPUT "Enter term"; n1
FOR i = 1 TO n1
INPUT "enter no"; n
IF n > 100 THEN
c = c + 1
ELSE
c1 = c1 + 1
END IF
NEXT i
PRINT "No greater than 100 = "; c
PRINT "No less than 100 = "; c1
END
Q.30 Write a qbasic program to input any number and print the summation of digits ? CLS
INPUT "Enter any no"; N
WHILE N <> 0
R = N MOD 10
S = S + R
N = INT(N/10)
WEND
PRINT "Sum of digit = "; S
END
Q.31 Write a qbasic program to input any Integer number & count how many prime digit in it ? CLS
INPUT "Enter any no"; n
WHILE <> 0
R = N MOD 10
FOR J = 2 TO R - 1
IF R MOD J = 0 THEN
P = 1
GOTO 50
END IF
N = INT(N/10)
P = 0
WEND
IF C > 0 THEN
PRINT "Total prime digits in number = ";c
ELSE
PRINT "Prime digit not found"
END IF
END
Q.32 Write a qbasic program to input any number and find out greatest and lowest digit ? CLS
INPUT "Enter any no"; n
WHILE n <> 0
r = n MOD 10
IF k = 1 THEN
g = r
l = r
k = k + 1
END IF
IF r > g THEN
g = r
END IF
IF r < 1 THEN
l = r
END IF
n = INT(n/10)
WEND
PRINT "Greatest digit = "; g
PRINT "Lowest digit = "; l
END
Q.33 Write a qbasic program to input any number print the summation of even and odd digit separately ? CLS
INPUT “Enter any no”; n
WHILE n <> 0
r = n MOD 10
IF r MOD 2 = 0 THEN
s = s + r
ELSE
s1 = s1 + r
END IF
n = INT(N/10)
WEND
PRINT "Sum of even digit = "; s
PRINT "Sum of odd digit = "; s1
END
Q.34 Write a qbasic program to input and check the number is palindrone or not ? CLS
INPUT "Enter any no"; n
a = n
WHILE <> 0
r = n MOD 10
s = s * 10 + r
n = INT(n/10)
WEND
IF a = s THEN
PRINT a; "is palindrome"
ELSE
PRINT a; "is not palindrome"
END IF
END
Q.35 Write a qbasic program to print the summation of number after inputting press 0 to ternimate the loop ? CLS
DO
INPUT "ENTER ANY NUMBER"; n
s = s + n
LOOP WHILE n<>0
print "Sum of numbers = "; s
END
Q.36 Write a qbasic program to input any number and count total prime digit from all the numbers, Press 0 for ternimation the loop ? CLS
INPUT "Enter any number"; n
a = n
WHILE n<>0
r = n MOD 10
p = p * 10 + r
n = INT(n/10)
WEND
IF a = p THEN
c = c + 1
END IF
p = 0
LOOP WHILE a <> 100
PRINT "Total palindrome number = "; c
END
Q.37 Write a qbasic program to input numbers & count total prime digit from all numbers, Press 0 to trnimate the loop ? CLS
INPUT "Enter any number"; n
a = n
WHILE n<>0
r = n MOD 10
for j = 2 to r - 1
IF r MOD j = 0 THEN
p = 1
GOTO 60
END IF
NEXT j
60 IF p = 0 THEN
c = c + 1
END IF
n = INT(n/10)
p = 0
WEND
LOOP WHILE a <> 0
PRINT "Total prime digit = "; c
END
Q.38 Write a qbasic program to input any number, if the number is palindrome then print the table of the number ? CLS
INPUT "Enter any number"; n
a = n
WHILE n<>0
r = n MOD 10
p = p * 10 + r
n = INT(n/10)
WEND
IF a = p THEN
FOR i = 1 to 10 n
PRINT a; "x"; i; "="; a * i
NEXT i
END IF
p = 0
LOOP WHILE a <> 100
END
Q.39 Write a qbasic program to input five number and display them in LIFO form ? CLS
DIM a(5)
FOR i = 0 to 4
INPUT "Enter any number"; a(i)
NEXT i
PRINT "Displaying number in lifo form"
FOR i = 4 to STEP - 1
PRINT a(i)
NEXT i
END
Q.40 Write a qbasic program to input five number and display even and odd in seperate dimension ? CLS
DIM n(5)
FOR i = 0 TO 4
INPUT "Enter any number"; n(i)
NEXT i
PRINT "Even numbers:"
FOR i = 0 TO 4
IF n(i) MOD 2 = 0 THEN
PRINT "n("; i; ")"; n(i)
END IF
NEXT i
PRINT "Odd numbers:"
FOR i = 0 TO 4
IF n(i) MOD 2 = 1 THEN
PRINT "n("; i; ")"; n(i)
END IF
NEXT i
END
Q.41 Write a qbasic program to input five number and display prime number with its dimension ? CLS
DIM n(5)
FOR i = 0 TO 4
INPUT "Enter any number"; n(i)
NEXT i
PRINT "Prime Numbers"
FOR i = 0 TO 4
FOR j = 1 TO n(i)
IF n(i) MOD j = 0 THEN
c = c + 1
END IF
NEXT j
IF c = 2 THEN
PRINT "n("; i; ")"; n(i)
END IF
c = 0
NEXT i
END
Q.42 Input number upto nth term and exchamge the place of the greatest and lowest number ? CLS
INPUT "enter term"; n
DIM a(n)
FOR i = 0 TO n - 1
INPUT "Enter any number"; a(i)
NEXT i
PRINT "Displaying elements"
FOR i = 0 TO n - 1
PRINT "a("; i; ")"; a(i)
NEXT i
FOR i = 0 TO n - 1
IF i = 0 THEN
g = a(i)
l = a(i)
END IF
IF a(i) > g THEN
g = a(i)
END IF
IF a(i) < l THEN
l = a(i)
END IF
NEXT i
FOR i = 0 TO n - 1
IF a(i) = l THEN
a(i) = g
GOTO 40
END IF
IF a(i) = g THEN
a(i) = l
END IF
40 NEXT i
PRINT "displaying elements after exchanging"
FOR i = 0 TO n - 1
PRINT "a("; i; ")"; a(i)
NEXT i
END
Q.43 Write a qbasic program to input number up to nth term and sort the number in ascending order ? CLS
INPUT "enter term"; n
DIM a(n)
FOR i = 0 TO n - 1
INPUT "enter any number"; a(i)
NEXT i
PRINT "Displaying elements"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
FOR i = 0 TO n - 1
FOR j = i + 1 TO n - 1
IF a(i) > a(j) THEN
t = a(i)
a(i) = a(j)
a(j) = t
END IF
NEXT j
NEXT i
PRINT "Displaying number after sorting"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
END
Q.44 Write a qbasic program to input number up to nth term and sort the number in descending order ? CLS
INPUT "enter term"; n
DIM a(n)
FOR i = 0 TO n - 1
INPUT "enter any number"; a(i)
NEXT i
PRINT "Displaying elements"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
FOR i = 0 TO n - 1
FOR j = 0 TO n - 1
IF a(i) > a(j) THEN
t = a(i)
a(i) = a(j)
a(j) = t
END IF
NEXT j
NEXT i
PRINT "Displaying number after sorting"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
END
Q.45 Write a qbasic program to input number up to nth term & after that input any other element shift the inputed element at the exact place where it can be shifted ? CLS
INPUT "enter term"; n
DIM a(n)
FOR i = 0 TO n - 1
INPUT "enter any number"; a(i)
NEXT i
PRINT "Displaying elements"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
REM selection sort
FOR i = 0 TO n - 2
FOR j = i + 1 TO n - 1
IF a(i) > a(j) THEN
t = a(i)
a(i) = a(j)
a(j) = t
END IF
NEXT j
NEXT i
PRINT "Displaying number after sorting"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
REM insertion sort
INPUT "enter any element to be inserted"; it
FOR i = n - 1 TO 0 STEP -1
IF it < a(i) THEN
a(i + 1) = a(i)
ELSE
GOTO 20
END IF
NEXT i
20 a(i + 1) = it
PRINT "Displaying elements after insertion sort"
FOR i = 0 TO n - 1
PRINT a(i)
NEXT i
END
Q.46 Write a qbasic program to input row & column & display matrix ? CLS
INPUT "enter row"; r
INPUT "Enter column"; c
DIM a(r, c)
FOR i = 0 TO r - 1
FOR j = 0 TO c - 1
INPUT "Enter elements"; a(i, j)
NEXT j
NEXT i
PRINT "Displaying matrix"
FOR i = 0 TO r - 1
FOR j = 0 TO c - 1
PRINT a(i, j);
NEXT j
PRINT
NEXT i
END
Q.47 Write a qbasic program to input row & column & display matrix's
(i)Row wise summation.
(ii)Column wise summation.
(iii)Left to right Diagonal wise summation.
(iv)Right to left Diagonal wise summation. CLS
INPUT "enter row"; r
INPUT "Enter column"; c
DIM a(r, c)
FOR i = 0 TO r - 1
FOR j = 0 TO c - 1
INPUT "Enter elements"; a(i, j)
NEXT j
NEXT i
PRINT "Displaying matrix"
FOR i = 0 TO r - 1
FOR j = 0 TO c - 1
PRINT a(i, j);
NEXT j
PRINT
NEXT i
REM row wise summation
FOR i = 0 TO r - 1
FOR j = 0 TO c - 1
s = s + a(i, j)
NEXT j
PRINT "Sum of row"; i + 1; "="; s
s = 0
NEXT i
REM column wise summation
FOR i = 0 TO r - 1
FOR j = 0 TO c - 1
s1 = s1 + a(j, i)
NEXT j
PRINT "Sum of column"; i + 1; "="; s1
s1 = 0
NEXT i
REM diagonal summation
FOR i = 0 TO r - 1
s3 = s3 + a(i, i)
NEXT i
c = c - 1
FOR i = 0 TO r - 1
s4 = s4 + a(i, c)
c = c - 1
NEXT i
PRINT "diagonal sum from left to right = "; s3
PRINT "diagonal some from ight to left = "; s4
END
Q.48 Write a qbasic program to input a string & find out the lenght of the string ? CLS
INPUT "enter any string"; n$
l = LEN(n$)
PRINT "lenght of string"; l
END
Q.49 Write a qbasic program to input any string & find out the ascii value of each charater ? CLS
INPUT "enter any string"; n$
l = LEN(n$)
PRINT "Character", "Ascii value"
FOR i = 1 TO l
m$ = MID$(n$, i, 1)
PRINT m$; TAB(20); ASC(m$)
NEXT i
END
Q.50 Write a qbasic program to input any string & find out which character ascii value is highest & which character ascii value is lowest ? CLS
INPUT "enter any string"; n$
l = LEN(n$)
FOR i = 1 TO l
m$ = MID$(n$, i, 1)
IF i = 1 THEN
g$ = m$
s$ = m$
END IF
IF m$ < s$ THEN
s$ = m$
END IF
IF m$ > g$ THEN
g$ = m$
END IF
NEXT i
PRINT "Highest ascii value character = "; g$
PRINT "lowest ascii value character = "; s$
END