SCHOOL PROGRAM



QBASIC PROGRAMS




Arithmetic programs
1.      Write a program to enter your name and print it .

CLS
Input “Enter you name”;n$
PRINT “THE NAME IS”;N$
END

USING SUB
DECLARE SUB NAME(N$)
CLS
Input “Enter you name”;n$
CALL NAME (N$)
END

SUB NAME(N$)
Print “The name is”; n$
END SUB

USING FUNCTION
DECLARE SUB NAME(N$)
CLS
Input “Enter you name”; n$
Print “The name is”; n$
END

FUNCTION NAME (N$)
END FUNCTION

2.      Write a program to enter your name, city, country, age and print them.

CLS
Input " Enter the name ";N$
Input " Enter the city"; C$
Input " Enter the country"; CO$
Input " Enter the age"; A
Print " The name is "; N$
Print " The city is "; C$
Print " The country is "; CO$
Print " The age is "; A
End


USING SUB

DECLARE SUB INTRO(N$,C$,CO$,A)
CLS
Input " Enter the name ";N$
Input " Enter the city"; C$
Input " Enter the country"; CO$
Input " Enter the age"; A
CALL INTRO (N$,C$,CO$,A)
END

SUB INTRO (N$,C$,CO$,A)
Print " The name is "; N$
Print " The city is "; C$
Print " The country is "; CO$
Print " The age is "; A
End SUB

USING FUNCTION
DECLARE FUNCTION INTRO (N$,C$,CO$,A)
CLS
Input " Enter the name ";N$
Input " Enter the city"; C$
Input " Enter the country"; CO$
Input " Enter the age"; A
Print " The name is "; N$
Print " The city is "; C$
Print " The country is "; CO$
Print " The age is "; A
End

FUNCTION INTRO (N$,C$,CO$,A)
END FUNCTION


3.      Write a program to find the area of rectangle.

Cls
Input
" enter the length " ;l
Input " enter the breadth " ;b
A = l*b
Print"
the area of rectangle=" ;a
End
USING SUB
DECLARE SUB AREA(L,B)
CLS
Input " enter the length " ;l
Input " enter the breadth " ;b
CALL AREA(L,B)
END

SUB AREA(L,B)
A = l*b
Print"
the area of rectangle=" ;a
End SUB

USING FUNCTION
DECLARE FUNCTION AREA(L,B)
CLS
Input " enter the length " ;l
Input " enter the breadth " ;b
A = l*b
Print"
the area of rectangle=" ;a
End
FUNCTION AREA(L,B)
END FUNCTION

4.      Write any number and find it's half.
Cls
Input "Enter the desired number "; N
H = N/2
Print "The half of the number = ";H
END

USING SUB
DECLARE SUB HALF(N)
CLS
Input "Enter the desired number "; N
CALL HALF(N)
END

SUB HALF(N)
H = N/2
Print "The half of the number = ";H
END SUB

USING FUNCTION
DECLARE FUNCTION HALF(N)
CLS
Input "Enter the desired number "; N
H = N/2
Print "The half of the number = ";H
END

            FUNCTION HALF (N)
            END FUNCTION


5.      Write a program to find the area of the triangle.

Cls
Input
" enter the base" ;b
Input " enter the height" ;h
T = 1/2*b*h
Print" The area of triangle=" ;T
End

USING SUB
DECLARE SUB AREA(B,H)
CLS
Input " enter the base" ;b
Input " enter the height" ;h
CALL AREA(B,H)
END
SUB AREA(B,H)
T = 1/2*b*h
Print" The area of triangle=" ;T
End SUB

USING FUNCTION
DECLARE FUNCTION AREA(B,H)
CLS
Input " enter the base" ;b
Input " enter the height" ;h
T = 1/2*b*h
Print" The area of triangle=" ;T
End

            FUNCTION AREA(B,H)
            END FUNCTION



6.      Write a program to find the area of the circle.

Cls
Input"
Enter the radius”; R
C=3.14*R^2
Print " The area of circle =”; C
End
USING SUB
DECLARE SUB AREA(R)
CLS
Input " enter the radius" ;R
CALL AREA(R)
END
SUB AREA(R)
C=3.14*R^2
Print " The area of circle =”; C
End SUB

USING FUNCTION
DECLARE FUNCTION AREA(R)
CLS
Input" Enter the radius”; R
C=3.14*R^2
Print " The area of circle =”; C
End
FUNCTION AREA(R)
END FUNCTION

7.      Write a program to find the circumference of the circle.

Cls
Input" Enter the radius " ;R
C=2*3.14*R
Print " The area of circle =" ;C
End

USING SUB
DECLARE SUB CIR(R)
CLS
Input " enter the radius" ;R
CALL CIR(R)
END

SUB CIR(R)
C=2*3.14*R
Print " The area of circle =" ;C
End SUB

USING FUNCTION
DECLARE FUNCTION CIR(R)
CLS
Input" Enter the radius”; R
C=2*3.14*R
Print " The area of circle =" ;C
End

FUNCTION CIR(R)
END FUNCTION

8.      Write a program to find the area of the square.

Cls
Input" Enter the number”; n
S= n^2
Print" The area of square=" ;S
End

USING SUB
DECLARE SUB AREA(N)
CLS
Input" Enter the number”; n
CALL AREA(N)
END
SUB AREA(N)
S= n^2
Print" The area of square=" ;S
End SUB

USING FUNCTION
DECLARE FUNCTION AREA(N)
CLS
Input" Enter the number”; n
S= n^2
Print" The area of square=" ;S
End

FUNCTION AREA(N)
END FUNCTION

9.      Write a program to find the area of the square and cube.

Cls
Input" Enter the number" ;n
S= n^2
C = n^3
Print" The area of square=" ;S
Print" The area of cube=" ; C
End

USING SUB
DECLARE SUB AREA(N)
CLS
Input" Enter the number”; n
CALL AREA(N)
END
SUB AREA(N)
S= n^2
C = n^3
Print" The area of square=" ;S
Print" The area of cube=" ; C
End SUB

USING FUNCTION
DECLARE FUNCTION AREA(N)
CLS
Input" Enter the number”; n
S= n^2
C = n^3
Print" The area of square=" ;S
Print" The area of cube=" ; C
End FUNCTION

10. Write a program to find the volume of the box.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
Input " enter the height " ;h
V= l*b*h
Print" The volume of box =" ;V
End

USING SUB
DECLARE SUB VOLUME(L,B,H)
CLS
Input " enter the length " ;l
Input " enter the breadth " ;b
Input " enter the height " ;h
CALL VOLUME(L,B,H)
END
SUB VOLUME(L,B,H)
V= l*b*h
Print" The volume of box =" ;V
End

USING FUNCTION
DECLARE FUNCTION VOLUME(L,B,H)
CLS
Input " enter the length " ;l
Input " enter the breadth " ;b
Input " enter the height " ;h
V= l*b*h
Print" The volume of box =" ;V
End

FUNCTION VOLUME(L,B,H)
END FUNCTION

10.  Write a program to convert the weight from kilogram to pounds.

CLS
INPUT
“Enter the weight in kilogram"; K
P=K*2.2
Print "The pound is "; P
End

USING SUB
DECLARE SUB POUNDS(K)
CLS
INPUT “Enter the weight in kilogram"; K
CALL POUNDS(K)
END
SUB POUNDS(K)
P=K*2.2
Print "The pound is "; P
End SUB

USING FUNCTION
DECLARE FUNCTION POUNDS(K)
CLS
INPUT “Enter the weight in kilogram"; K
P=K*2.2
Print "The pound is "; P
End

FUNCTION POUNDS(K)
END FUNCTION

11.  Write a program to convert the distance from kilometer to miles.

Cls
Input
" Enter the length in kilometer"; K
M= K / 1.6
Print "The length in miles ="; M
End

USING SUB
DECLARE SUB MILES(K)
CLS
INPUT “Enter the weight in kilometer"; K
CALL MILES(K)
END
SUB MILES(K)
M= K / 1.6
Print "The length in miles ="; M
End sub

USING FUNCTION
DECLARE FUNCTION MILES(K)
CLS
Input" Enter the length in kilometer"; K
M= K / 1.6
Print "The length in miles ="; M
End
FUNCTION MILES(K)
END FUNCTION

12.  Write a program to convert the distance from miles to kilometers.

Cls
Input “Enter the length in miles"; M
K=M*1.6
Print" The length in kilo meters="; K
End

USING SUB
DECLARE SUB KM(M)
CLS
Input “Enter the length in miles"; M
CALL KM(M)
END
SUB KM(M)
K=M*1.6
Print" The length in kilo meters="; K
End SUB

USING FUNCTION
DECLARE FUNCTION KM(M)
CLS
Input “Enter the length in miles"; M
K=M*1.6
Print" The length in kilo meters="; K
End

FUNCTION KM(M)
END FUNCTION

13.  Write a program to enter the initial mileage (m1) and final mileage (m2) then calculate the distance traveled.

CLS
Input "
Enter the Initial Mileage"; M1
Input "Enter the Final Mileage"; M2
D= M2-M1
Print " The distance covered="; D
End

USING SUB
DECLARE SUB DIS(M1,M2)
CLS
Input "Enter the Initial Mileage"; M1
Input "Enter the Final Mileage"; M2
CALL DIS(M1,M2)
END
SUB DIS(M1,M2)
D= M2-M1
Print " The distance covered="; D
End SUB

USING FUNCTION
DECLARE FUNCTION DIS(M1,M2)
CLS
Input "Enter the Initial Mileage"; M1
Input "Enter the Final Mileage"; M2
D= M2-M1
Print " The distance covered="; D
End
FUNCTION DIS(M1,M2)
END FUNCTION


14.  Write a program to find out the simple Interest.

Cls
Input “Enter the Principal"; P
Input “Enter the Rate"; R
Input “Enter the Time"; T
I = (P*T*R)/100
Print " The simple Interest = ";I
End

USING SUB
DECLARE SUB INT(P,T,R)
CLS
Input “Enter the Principal"; P
Input “Enter the Rate"; R
Input “Enter the Time"; T
CALL INT(P,T,R)
END
SUB INT(P,T,R)
I = (P*T*R)/100
Print " The simple Interest = ";I
End SUB

USING FUNCTION
DECLARE FUNCTION INT(P,T,R)
CLS
Input “Enter the Principal"; P
Input “Enter the Rate"; R
Input “Enter the Time"; T
I = (P*T*R)/100
Print " The simple Interest = ";I
End

FUNCTION INT(P,T,R)
END FUNCTION

15.  Write a program to find out the simple Interest and the Amount.

Cls
Input “Enter the Principal"; P
Input “Enter the Rate"; R
Input “Enter the Time"; T
I = (P*T*R)/100
A= P + I
Print " The simple Interest = "; I
Print " The amount="; A
End

USING SUB
DECLARE SUB INT(P,T,R)
CLS
Input “Enter the Principal"; P
Input “Enter the Rate"; R
Input “Enter the Time"; T
CALL INT(P,T,R)
END
SUB INT(P,T,R)
I = (P*T*R)/100
A= P + I
Print " The simple Interest = "; I
Print " The amount="; A
End SUB

USING FUNCTION
DECLARE FUNCTION INT(P,T,R)
CLS
Input “Enter the Principal"; P
Input “Enter the Rate"; R
Input “Enter the Time"; T
I = (P*T*R)/100
A= P + I
Print " The simple Interest = "; I
Print " The amount="; A
End

FUNCTION INT(P,T,R)
END FUNCTION

16.  Write a program to find the area of four walls of a room.

Cls
Input"
Enter the height "; H
Input" Enter the length "; L
Input" Enter the Breadth"; B
A= 2 * H * (L+B)
Print " The area of four walls ="; A
End

USING SUB
DECLARE SUB AREA(H,L,B)
CLS
Input" Enter the height "; H
Input" Enter the length "; L
Input" Enter the Breadth"; B
CALL AREA(H,L,B)
END

SUB AREA(H,L,B)
A= 2 * H * (L+B)
Print " The area of four walls ="; A
End

USING FUNCTION
DECLARE FUNCTION AREA(H,L,B)
CLS
Input" Enter the height "; H
Input" Enter the length "; L
Input" Enter the Breadth"; B
A= 2 * H * (L+B)
Print " The area of four walls ="; A
End

FUNCTION  AREA(H,L,B)
END FUNCTION

17.  Write a program to find the perimeter of a rectangle.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
P=2*(l+b)
Print" The perimeter of rectangle=" ;P
End

USING SUB
DECLARE SUB PER(L,B)
CLS
Input" Enter the length "; L
Input" Enter the Breadth"; B
CALL PER(L,B)
END
SUB PER(L,B)
P=2*(l+b)
Print" The perimeter of rectangle=" ;P
End SUB

USING FUNCTION
DECLARE FUNCTION PER(L,B)
CLS
Input " enter the length " ;l
Input " enter the breadth " ;b
P=2*(l+b)
Print" The perimeter of rectangle=" ;P
End

FUNCTION PER(L,B)
END FUNCTION

18.  Write a program to enter any three numbers, sum and the average.

Cls
Input " Enter any number" ;A
Input " Enter any number" ;B
Input " Enter any number" ;C
S = A+B+C
Av =S/3
Print" The sum=" ;S
Print" The Average is " ;Av
End

USING SUB
DECLARE SUB AVG(A,B,C)
CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
Input " Enter any number" ;C
CALL AVG(A,B,C)
END
SUB AVG(A,B,C)
S = A+B+C
Av =S/3
Print" The sum=" ;S
Print" The Average is " ;Av
End SUB


USING FUNCTION
DECLARE FUNCTION AVG(A,B,C)
CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
Input " Enter any number" ;C
S = A+B+C
Av =S/3
Print" The sum=" ;S
Print" The Average is " ;Av
End
FUNCTION AVG(A,B,C)
END FUNCTION

19.  Write a program to enter any two numbers their Sum, Product and the Difference.

CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
S = A+B
D= A-B
P = A*B
Print" the SUM =" ;S
Print" the Difference =" ;D
Print" the Product =" ; P
End

USING SUB
DECLARE SUB SPD(A,B)
CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
CALL SPD(A,B)
END
SUB SPD(A,B)
S = A+B
D= A-B
P = A*B
Print" the SUM =" ;S
Print" the Difference =" ;D
Print" the Product =" ; P
End SUB

USING FUNCTION
DECLARE FUNCTION SPD(A,B)
CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
S = A+B
D= A-B
P = A*B
Print" the SUM =" ;S
Print" the Difference =" ;D
Print" the Product =" ; P
End

FUNCTION SPD(A,B)
END FUNCTION

20.  Write a program to find the average of three different numbers.

Cls
Input" Enter the number " ;A
Input" Enter the number " ;B
Input" Enter the number " ;C
Av= (A+B+C)/3
Print" The average=" ; Av
End
USING SUB
DECLARE SUB AVG(A,B,C)
CLS
Input" Enter the number " ;A
Input" Enter the number " ;B
Input" Enter the number " ;C
CALL AVG(A,B,C)
END
SUB AVG(A,B,C)
Av= (A+B+C)/3
Print" The average=" ; Av
End SUB
USING FUNCTION
DECLARE FUNCTION AVG(A,B,C)
CLS
Input" Enter the number " ;A
Input" Enter the number " ;B
Input" Enter the number " ;C
Av= (A+B+C)/3
Print" The average=" ; Av
END
FUNCTION AVG(A,B,C)
END FUNCTION

21.  Write a program to input student's name, marks obtained in four different subjects, find the total and average marks.

Cls
Input
" Enter the name " ;N$
Input" Enter the marks in English" ;E
Input" Enter the marks in Maths" ;M
Input" Enter the marks in Science" ;S
Input" Enter the marks in Nepali" ;N
S=E+M+S+N
A=S/4
Print " The name of the student is" ;N$
Print " The total marks is" ;S
Print " The Average marks" ;A
End

USING SUB
DECLARE SUB RES(N$,E,M,S,N)
CLS
Input" Enter the name " ;N$
Input" Enter the marks in English" ;E
Input" Enter the marks in Maths" ;M
Input" Enter the marks in Science" ;S
Input" Enter the marks in Nepali" ;N
CALL RES(N$,E,M,S,N)
END

SUB RES(N$,E,M,S,N)
S=E+M+S+N
A=S/4
Print " The name of the student is" ;N$
Print " The total marks is" ;S
Print " The Average marks" ;A
End SUB

USING FUNCTION
DECLARE FUNCTION RES(N$,E,M,S,N)
CLS
Input" Enter the name " ;N$
Input" Enter the marks in English" ;E
Input" Enter the marks in Maths" ;M
Input" Enter the marks in Science" ;S
Input" Enter the marks in Nepali" ;N
S=E+M+S+N
A=S/4
Print " The name of the student is" ;N$
Print " The total marks is" ;S
Print " The Average marks" ;A
End

FUNCTION RES(N$,E,M,S,N)
END FUNCTION
22.  Write a program to find 10% of the input number.

Cls
Input" Enter any number”; N
T=10/100*N
Print " 10%of input number=“; T
End

USING SUB
DECLARE SUB PER(N)
CLS
Input" Enter any number”; N
CALL PER(N)
END
SUB PER(N)
T=10/100*N
Print " 10%of input number=“; T
End SUB

USING FUNCTION
DECLARE FUNCTION PER(N)
CLS
Input" Enter any number”; N
T=10/100*N
Print " 10%of input number=“; T
End
FUNCTION PER(N)
END FUNCTION

23.  Write a program to find the perimeter of square.

Cls
Input "Enter the length"; L
P =4 * L
Print " The perimeter of square=";P
End

USING SUB
DECLARE SUB PER(L)
CLS
Input "Enter the length"; L
CALL PER(N)
END
SUB PER(N)
P =4 * L
Print " The perimeter of square=";P
End SUB



USING FUNCTION
DECLARE FUNCTION PER(N)
CLS
Input "Enter the length"; L
P =4 * L
Print " The perimeter of square=";P
End
FUNCTION PER(N)
END FUNCTION

24.  Write a program to enter the Nepalese currency and covert it to Indian Currency.

CLS
Input "Enter the Nepalese currency”; N
I = N * 1.6
Print "the Indian currency="; I
End

USING SUB
DECLARE SUB CUR(N)
CLS
Input "Enter the Nepalese currency”; N
CALL CUR(N)
END
SUB CUR(N)
I = N * 1.6
Print "the Indian currency="; I
End SUB


USING FUNCTION

DECLARE FUNCTION CUR(N)
CLS
Input "Enter the Nepalese currency”; N
I = N * 1.6
Print "the Indian currency="; I
End
FUNCTION CUR(N)
END FUCTION

25.  Write a program to enter the Indian currency and covert it to Nepalese Currency.

CLS
Input "Enter the Indian currency”; I
N = I / 1.6
Print "the Nepalese currency="; N
End

USING SUB
DECLARE SUB CUR(I)
CLS
Input "Enter the Indian currency”; I
CALL CUR(I)
END
SUB CUR(N)
N = I / 1.6
Print "the Nepalese currency="; N
End SUB

USING FUNCTION

DECLARE FUNCTION CUR(N)
CLS
Input "Enter the Indian currency”; I
N = I / 1.6
Print "the Nepalese currency="; N
End
FUNCTION CUR(N)
END FUCTION

26.  Write a program to input temperature in centigrade and convert it into Fahrenheit.
CLS
INPUT” Enter temp in centigrade=”;C
F=C*9/5+32
PRINT” Temp in Fahenheit=”;F
END

USING SUB
DECLARE SUB TEMP(C)
CLS
INPUT” Enter temp in centigrade=”;C
CALL TEMP(C)
END
SUB TEMP(C)
F=C*9/5+32
PRINT” Temp in Fahenheit=”;F
END SUB

USING FUNCTION

DECLARE FUNCTION TEMP(C)
CLS
INPUT” Enter temp in centigrade=”;C
F=C*9/5+32
PRINT” Temp in Fahenheit=”;F
END
FUNCTION TEMP(C)
END FUNCTION



LOOPING PROGRAMS

27.  Write a program to print division of input marks.
CLS
INPUT”ENTER MARKS”;M
IF M>=80 THEN
PRINT “DISTINCTION”
ELSEIF M>=60 AND M<80 THEN
PRINT “FIRST DIVISION”
ELSEIF M>=50 AND M<60 THEN
PRINT “SECOND DIVISION”
ELSEIF M>=40 AND M<50 THEN
PRINT “THIRD DIVISION “
ELSE
PRINT” FAIL”
END IF
END

USING SUB
DECLARE SUB RESULT(M)
CLS
INPUT”ENTER THE MARKS”;M
CALL RESULT(M)
END
SUB RESULT(M)
IF M>=80 THEN
PRINT “DISTINCTION”
ELSEIF M>=60 AND M<80 THEN
PRINT “FIRST DIVISION”
ELSEIF M>=50 AND M<60 THEN
PRINT “SECOND DIVISION”
ELSEIF M>=40 AND M<50 THEN
PRINT “THIRD DIVISION “
ELSE
PRINT” FAIL”
END IF
END SUB

USING FUNCTION
DECLARE FUNCTION RESULT (M)
CLS
INPUT”ENTER MARKS”;M
IF M>=80 THEN
PRINT “DISTINCTION”
ELSEIF M>=60 AND M<80 THEN
PRINT “FIRST DIVISION”
ELSEIF M>=50 AND M<60 THEN
PRINT “SECOND DIVISION”
ELSEIF M>=40 AND M<50 THEN
PRINT “THIRD DIVISION “
ELSE
PRINT” FAIL”
END IF
END
FUNCTION RESULT(M)
END FUNCTION

28.  Write a program to enter any number and find out whether it is negative or positive.

CLS
Input "Enter the number"; N
If N>0 Then
Print “The number is positive"
Else
Print "The number is negative"
EndIf
End

USING SUB
DECLARE SUB PN(N)
CLS
Input "Enter the number"; N
CALL  PN(N)
END
SUB  PN(N)
If N>0 Then
Print “The number is positive"
Else
Print "The number is negative"
EndIf
End SUB

USING FUNCTION

DECLARE FUNCTION PN(N)
CLS
If N>0 Then
Print “The number is positive"
Else
Print "The number is negative"
EndIf
End
FUNCTION  PN(N)
END FUNCTION

29.  Write a program to check the entered character is vowel or constant.
CLS
INPUT”Enter the character”; CH$
IF CH$=”A” OR CH$=”E” OR CH$=”I” OR CH$=”O” OR CH$=”U” OR CH$=”a” OR CH$=”e” OR CH$=”o” OR CH$=”u” THEN
PRINT “The character is vowel”
ELSE
PRINT”the character is constant”
END IF
END


USING SUB
DECLARE SUB VOWEL(CH$)
CLS
Input "Enter the Character"; CH$
CALL  VOWEL(CH$)
END
SUB  VOWEL(CH$)
IF CH$=”A” OR CH$=”E” OR CH$=”I” OR CH$=”O” OR CH$=”U” OR CH$=”a” OR CH$=”e” OR CH$=”o” OR CH$=”u” THEN
PRINT “The character is vowel”
ELSE
PRINT”the character is constant”
END IF
END SUB

USING FUNCTION

DECLARE FUNCTION VOWEL(CH$)
CLS
INPUT”Enter the character”; CH$
IF CH$=”A” OR CH$=”E” OR CH$=”I” OR CH$=”O” OR CH$=”U” OR CH$=”a” OR CH$=”e” OR CH$=”o” OR CH$=”u” THEN
PRINT “The character is vowel”
ELSE
PRINT”the character is constant”
END IF
END
FUNCTION VOWEL(CH$)
END FUNCTION

30.  Write a program to enter any number and find out whether it is even or odd .
Cls
Input "Enter any number" ;N
IF N MOD 2 = 0 THEN
Print "The number is Even number"
ELSE
Print "The number is odd number"
End IF
End

USING SUB
DECLARE SUB ODDEVEN(N)
CLS
Input "Enter the number"; N
CALL  ODDEVEN (N)
END
SUB  ODDEVEN (N)
IF N MOD 2 = 0 THEN
Print "The number is Even number"
ELSE
Print "The number is odd number"
End IF
End SUB

USING FUNCTION

DECLARE FUNCTION ODDEVEN(N)
CLS
Input "Enter any number" ;N
IF N MOD 2 = 0 THEN
Print "The number is Even number"
ELSE
Print "The number is odd number"
End IF
End
FUNCTION ODDEVEN(N)
END FUNCTION

31.  Write a program to find the division by input marks using select case statement.
CLS
INPUT”ENTER THE MARKS”;M
SELECT CASE M
CASE 80 TO 100
PRINT “DIST”
CASE 60 TO 79
PRINT”FIRST”
CASE 50 TO 59
PRINT “SECOND”
CASE 40 TO 49
PRINT “THIRD”
CASE ELSE
PRINT” FAIL”
END SELECT

32.  Write a program to check the numbers between 1 & 3.

Cls
Input "Enter the numbers between 1-3";N
Select case N
Case 1
Print "It's number 1";
Case 2
Print "It's a number 2";
Case 3
Print "It's a number 3"
Case else
Print "It's out of range";
End select
End

USING SUB
DECLARE SUB NUM(N)
CLS
Input "Enter the number"; N
CALL  NUM(N)
END
SUB  NUM(N)
Select case N
Case 1
Print "It's number 1";
Case 2
Print "It's a number 2";
Case 3
Print "It's a number 3"
Case else
Print "It's out of range";
End select
End SUB
 
USING FUNCTION

DECLARE FUNCTION NUM(N)
CLS
Input "Enter the numbers between 1-3";N
Select case N
Case 1
Print "It's number 1";
Case 2
Print "It's a number 2";
Case 3
Print "It's a number 3"
Case else
Print "It's out of range";
End select
End
FUNCTION  NUM(N)
END FUNCTION

33.  Write a program to enter any alphabet and find out whether the number is vowel or alphabet.

Cls

Input "Enter Alphabet Letters"; A$
A$ = UCase$ (A$)
Select case A$
Case "A", "E", "I", "O", "U"
Print "
Its' a vowel"
Case Else
Print "
It's not a vowel"
End Select
End

USING SUB
DECLARE SUB VOWEL(A$)
CLS
Input "Enter Alphabet Letters"; A$
CALL VOWEL(A$)
END

SUB VOWEL(A$)
A$ = UCase$ (A$)
Select case A$
Case "A", "E", "I", "O", "U"
Print "
Its' a vowel"
Case Else
Print "
It's not a vowel"
End Select
End SUB

USING FUNCTION

DECLARE FUNCTION SUB VOWEL(A$)
CLS
Input "Enter Alphabet Letters"; A$
A$ = UCase$ (A$)
Select case A$
Case "A", "E", "I", "O", "U"
Print "
Its' a vowel"
Case Else
Print "
It's not a vowel"
End Select
End

FUNCTION  VOWEL(A$)
END FUNCTION


34.  Generate the following numbers using For……NEXT Loop.
1 2 3 ………….50

CLS
LET A=1
For I = A to 50
PRINT I;
Next I
End


USING SUB
DECLARE SUB SERIES(A)
CLS
LET A=1
CALL SERIES(A)
END

SUB SERIES(A)
For I = A to 50
PRINT I;
Next I
End SUB

USING FUNCTION

DECLARE FUNCTION SUB SERIES(A)
CLS
LET A=1
For I = A to 50
PRINT I;
Next I
End

FUNCTION SERIES(A)
END FUNCTION

35.  Generate the following numbers using For……….Next Loop.
1,3,5,7,9,....99

Cls
LET A=1
For
I = A to 99 Step 2
Print I
Next I
End

USING SUB

DECLARE SUB SERIES(A)
CLS
LET A=1
CALL SERIES(A)
END

SUB SERIES(A)
For I = A to 99 Step 2
Print I
Next I
End SUB


USING FUNCTION

DECLARE FUNCTION SUB SERIES(A)
CLS
LET A=1
For I = A to 99 Step 2
Print I
Next I
End

FUNCTION SERIES(A)
END FUNCTION

36.  Generate the following numbers using For……….NEXT. Loop.
2 4 6 8 10 …………….. 50
Cls
LET A=2
For I = A to 50 Step 2
Print I ;
NEXT I
END

USING SUB

DECLARE SUB SERIES(A)
CLS
LET A=2
CALL SERIES(A)
END

SUB SERIES(A)
For I = A to 50 Step 2
Print I ;
NEXT I
END SUB

USING FUNCTION

DECLARE FUNCTION SUB SERIES(A)
CLS
LET A=2
For I = A to 50 Step 2
Print I ;
NEXT I
END


FUNCTION SERIES(A)
END FUNCTION

37.  Generate the following numbers using For………..Next Loop.
5 10 15…………………..90

Cls
LET A=5
For I
= 5 to 90 Step 5
Print I
Next I
End

USING SUB

DECLARE SUB SERIES(A)
CLS
LET A=5
CALL SERIES(A)
END

SUB SERIES(A)
For I = 5 to 90 Step 5
Print I
Next I
End SUB

USING FUNCTION

DECLARE FUNCTION SUB SERIES(A)
CLS
LET A=5
For I
= 5 to 90 Step 5
Print I
Next I
End

FUNCTION SERIES(A)
END FUNCTION





38.  Generate the following numbers using For……………...Next Loop.
10 20 30 40 ………………. 100.

Cls
LET A=10
For I = 10 to 100 Step 10
Print I
Next I
End

USING SUB

DECLARE SUB SERIES(A)
CLS
LET A=10
CALL SERIES(A)
END

SUB SERIES(A)
For I = 10 to 100 Step 10
Print I
Next I
End SUB

USING FUNCTION

DECLARE FUNCTION SUB SERIES(A)
CLS
LET A=10
For I = 10 to 100 Step 10
Print I
Next I
End

FUNCTION SERIES(A)
END FUNCTION

39.  Write a program to print numbers stated below USING WHILE………….WEND STATEMENT.
1 2 3 4 ……… 100

Cls
I = 1
While I<=100
Print I ;
I = I + 1
WEND
END

USING SUB

DECLARE SUB SERIES(I)
CLS
I = 1
CALL SERIES(I)
END

SUB SERIES(A)
While I<=100
Print I ;
I = I + 1
WEND
END SUB

USING FUNCTION

DECLARE FUNCTION SUB SERIES(I)
CLS
I = 1
While I<=100
Print I ;
I = I + 1
WEND
END

FUNCTION SERIES(I)
END FUNCTION

40.  Generate the following numbers using WHILE………….WEND Loop.
2 4 6 8 10 …………….. 50

CLS
I = 2
While I < =50
Print I;
I = I + 2
WEND
END

USING SUB

DECLARE SUB SERIES(I)
CLS
I = 2
CALL SERIES(I)
END

SUB SERIES(I)
While I < =50
Print I;
I = I + 2
WEND
END SUB

USING FUNCTION

DECLARE FUNCTION SUB SERIES(I)
CLS
I = 2
While I < =50
Print I;
I = I + 2
WEND
END

FUNCTION SERIES(I)
END FUNCTION

41.  Write a program to print numbers stated below USING WHILE…………WEND STATEMENT.
1,3,5,7,9…………….99
CLS
I = 1
While I <=99
Print I ; “,” ;
I = I + 2
WEND
END


USING SUB

DECLARE SUB SERIES(I)
CLS
I = 1
CALL SERIES(I)
END

SUB SERIES(I)
While I <=99
Print I ; “,” ;
I = I + 2
WEND
END SUB


USING FUNCTION

DECLARE FUNCTION SUB SERIES(I)
CLS
I = 1
While I <=99
Print I ; “,” ;
I = I + 2
WEND
END


FUNCTION SERIES(I)
END FUNCTION

42.  Write a program to print numbers stated below USING WHILE…………WEND STATEMENT.
1,4,9 up to 10th term.
CLS
I=1
While I < =10
Print I^2;
I = I + 1
WEND
END

USING SUB

DECLARE SUB SERIES(I)
CLS
I = 1
CALL SERIES(I)
END

SUB SERIES(I)
While I < =10
Print I^2;
I = I + 1
WEND
END SUB


USING FUNCTION

DECLARE FUNCTION SUB SERIES(I)
CLS
I = 1
While I < =10
Print I^2;
I = I + 1
WEND
END

FUNCTION SERIES(I)
END FUNCTION

43.  Program to check a given string is palindrome or not in qbasic
CLS
INPUT "ENTER A STRING"; S$
FOR I = LEN(S$) TO 1 STEP -1
M$ = M$+MID$(S$, I, 1)
NEXT I
IF M$ = S$ THEN
PRINT "THE GIVEN STRING IS PALINDROME"
ELSE
PRINT "IT IS NOT PALINDROME"
END IF
END

Using declare sub
DECLARE SUB PALENDROME(S$)
CLS
INPUT "ENTER A STRING"; S$
CALL PALENDROME (S$)
END
SUB PALENDROME (S$)
FOR I = LEN(S$) TO 1 STEP -1
M$ = M$+MID$(S$, I, 1)
NEXT I
IF S$ = MID$ THEN
PRINT "THE GIVEN STRING IS PALINDROME"
ELSE
PRINT "IT IS NOT PALINDROME"
END IF
END SUB
USING DECLARE FUNCTION
DECLARE FUNCTION PALANDROME(S$)
CLS
INPUT "ENTER A STRING"; S$
M$ = M$+MID$(S$, I, 1)
NEXT I
IF M$ = S$ THEN
PRINT "THE GIVEN STRING IS PALINDROME"
ELSE
PRINT "IT IS NOT PALINDROME"
END IF
END
FUNCTION PALANDROME(S$)
END FUNCTION                                
44.  Program to check given number is Armstrong or not in basic
CLS
INPUT "ENTER A NUMBER"; N
T = N
DO WHILE N <> 0
R = N MOD 10
Q = R ^ 3
S=S+Q
N = INT(N / 10)
LOOP
IF T = STHEN
PRINT "THE GIVEN NUMBER IS ARMSTRONG"
ELSE
PRINT "IT IS NOT ARMSTRONG"
END IF
END

Using declare sub procedure
DECLARE SUB ARM(N)
CLS
INPUT "ENTER A NUMBER"; N
CALL ARM(N)
END
SUB ARM(N)
T = N
DO WHILE N <> 0
R = N MOD 10
Q = R ^ 3
S=S+Q
N = INT(N / 10)
LOOP
IF T = STHEN
PRINT "THE GIVEN NUMBER IS ARMSTRONG"
ELSE
PRINT "IT IS NOT ARMSTRONG"
END IF
END SUB

USING DECLARE FUNCTION
DECLARE FUNCTION ARM(N)
CLS
INPUT "ENTER A NUMBER"; N
T = N
DO WHILE N <> 0
R = N MOD 10
Q = R ^ 3
S=S+Q
N = INT(N / 10)
LOOP
IF T = STHEN
PRINT "THE GIVEN NUMBER IS ARMSTRONG"
ELSE
PRINT "IT IS NOT ARMSTRONG"
END IF
END
FUNCTION ARM(S$)
END FUNCTION


45.  Program to reverse a given STRING in basic
CLS
INPUT "ENTER A STRING"; A$
FOR I= LEN (A$) TO 1 STEP -1
PRINT MID$(A$,I,1);
NEXT I
END

Using declare sub procedure
DECLARE SUB REV(A$)
CLS
INPUT "ENTER A STRING"; A$
CALL REV(A$)
END
SUB REV(A$)
FOR I= LEN (A$) TO 1 STEP -1
PRINT MID$(A$,I,1);
NEXT I
END SUB

USING DECLARE FUNCTION
DECLARE FUNCTION REV(A$)
CLS
INPUT "ENTER A STRING"; A$
FOR I= LEN (A$) TO 1 STEP -1
PRINT MID$(A$,I,1);
NEXT I
END
FUNCTION REV(A$)
END FUNCTION

46.  Program check given number is prime or composite
CLS
INPUT "ENTER A NUMBER"; N
FOR I = 2 TO (N-1)
S=N/I
T=INT(S)
IF S=T THEN
PRINT “THIS NUMBER IS NOTPRIME”
END
END IF
NEXT I
PRINT “THIS NUMBER IS PRIME”
END

Using declare sub procedure
DECLARE SUB PON(N)
CLS
INPUT "ENTER A NUMBER"; N
CALL PON(N)
END
SUB PON(N)
FOR I = 2 TO (N-1)
S=N/I
T=INT(S)
IF S=T THEN
PRINT “THIS NUMBER IS NOTPRIME”
END
END IF
NEXT I
PRINT “THIS NUMBER IS PRIME”
END SUB

DECLARE FUNCTION PON(N)
CLS
INPUT "ENTER A NUMBER"; N
FOR I = 2 TO (N-1)
S=N/I
T=INT(S)
IF S=T THEN
PRINT “THIS NUMBER IS NOTPRIME”
END
END IF
NEXT I
PRINT “THIS NUMBER IS PRIME”
END
FUNCTION PON (N)
END FUNCTION

47.  Write a program to find out the age group on the basic of age.
CLS
INPUT”Enter age of person=”;A
IF A>0 AND A<=10 THEN
PRINT “Child”
ELSEIF A>10 AND A<=19 THEN
PRINT”Teenage”
ELSEIF A>19 AND A<=40 THEN
PRINT”Young”
ELSE
PRINT “Old”
END IF
END

USING SUB
DECLARE SUB AG (A)
CLS
INPUT”ENTER THE AGE OF A PERSON=”;A
CALL SUB AG(A)
END
SUB AG(A)
IF A>0 AND A<=10 THEN
PRINT “Child”
ELSEIF A>10 AND A<=19 THEN
PRINT”Teenage”
ELSEIF A>19 AND A<=40 THEN
PRINT”Young”
ELSE
PRINT “Old”
END IF
END SUB

USING FUNCTION
DECLARE FUNCTION AG(A)
CLS
INPUTE”ENTER THE AGE OF A PERSON=”;A
IF A>0 AND A<=10 THEN
PRINT “Child”
ELSEIF A>10 AND A<=19 THEN
PRINT”Teenage”
ELSEIF A>19 AND A<=40 THEN
PRINT”Young”
ELSE
PRINT “Old”
END IF
END
FUNCTION AG(A)
END FUNCTION

48.  Write a program to print first 20 Fibonacci series. 1 1 2 3………20th term.
49.  Write a program to find sum of N numbers.
CLS
A=1
FOR I=A TO 10
S=S+I
PRINT S;
NEXT I
END

USING SUB
DECLARE SUB SERIES (A)
CLS
LET A=1
CALL SERIES(A)
END
SUB SERIES(A)
FOR I=A TO 10
S=S+I
PRINT S;
NEXT I
END SUB

USING FUNCTION
DECLARE FUNCTION SERIES(A)
CLS
A=1
FOR I=A TO 10
S=S+I
PRINT S;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION




50.  Write a program to find sum of first 50 even numbers.
CLS
A=2
FOR I =  A TO 100 STEP 2
S=S+I
PRINT S;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=2
CALL SERIES(A)
END
SUB SERIES (A)
FOR I =  A TO 100 STEP 2
S=S+I
PRINT S;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=2
FOR I =  A TO 100 STEP 2
S=S+I
PRINT S;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION

51.  Write a program to find sum of first 100 odd numbers.
CLS
A=1
FOR I= A TO 200 STEP 2
S=S+I
PRINT S;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=1
CALL SERIES(A)
END
SUB SERIES (A)
FOR I= A TO 200 STEP 2
S=S+I
PRINT S;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=1
FOR I= A TO 200 STEP 2
S=S+I
PRINT S;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION


52.  Write a program to generate the following series. 1 4 9 16 …..100
CLS
A = 1
FOR I = A TO 10
S = I^2
PRINT S;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=1
CALL SERIES(A)
END
SUB SERIES (A)
FOR I = A TO 10
S = I^2
PRINT S;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=1
FOR I = A TO 10
S = I^2
PRINT S;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION



53.  Write a program to generate the following series. 2 8 18 32 ………10th term.
CLS
A=1
FOR I = A TO 10
PRINT (I^2)*2;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=1
CALL SERIES(A)
END
SUB SERIES (A)
FOR I = A TO 10
PRINT (I^2)*2;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=1
FOR I = A TO 10
PRINT (I^2)*2;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION

54.  Write a program to generate the following series. 1 8 27 64………70
CLS
A=1
FOR I=A TO 10
PRITN I^3;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=1
CALL SERIES(A)
END
SUB SERIES (A)
FOR I=A TO 10
PRITN I^3;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=1
FOR I=A TO 10
PRITN I^3;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION

55.  Write a program to generate the following series. 100 90 80……….10
CLS
A=1
FOR I = 100 TO 10 STEP -10
PRINT I;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=1
CALL SERIES(A)
END
SUB SERIES (A)
FOR I = 100 TO 10 STEP -10
PRINT I;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=1
FOR I = 100 TO 10 STEP -10
PRINT I;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION

56.  Write a program to generate the following series. 5 55 555 5555 55555
CLS
A=5
FOR I = 1 TO 5
X=X*10*5
PRINT X;
NEXT I
END

USING SUB
DECLARE SUB SERIES(A)
CLS
A=5
CALL SERIES(A)
END
SUB SERIES (A)
FOR I = 1 TO 5
X=X*10*5
PRINT X;
NEXT I
END SUB

USING FUNCTION(A)
DECLARE FUNCTION (A)
CLS
A=5
FOR I = 1 TO 5
X=X*10*5
PRINT X;
NEXT I
END
FUNCTION SERIES(A)
END FUNCTION

57.  Write a program to generate the following difference pattern from word of “PALPA”.

i)                    PALPA                 ii) PALPA       iii) A                            iv)  P                v )  PA LPA   
PALP                        ALPA               PA                                PL                                 ALP      
PAL                          LPA                              LPA                             PAL                     L        
PA                             PA                     ALPA                          PALP      
P                                A                       PALPA                        PALPA

vi)       L                                  vii) PAL            viii) ALP                   ix) PLA           x) APLAP
        ALP
      PALPA


i)                    CLS
LET A$=”PALPA”
FOR I= LEN(A$) TO 1 STEP -1
PRINT LEFT$(A$,I)
NEXT I
END

ii)                  CLS
LET A$=”PALPA”
FOR I= LEN(A$) TO 1 STEP -1
PRINT RIGHT$(A$,I)
NEXT I
END

iii)                CLS
LET A$=”PALPA”
FOR I= 1 TO  LEN(A$)
PRINT RIGHT$(A$,I)
NEXT I
END

iv)                CLS
LET A$=”PALPA”
FOR I= 1 TO  LEN(A$)
PRINT LEFT$(A$,I)
NEXT I
END

v)                  CLS
LET A$=”PALPA”
C=5 : T=30
FOR I=1 TO 5 STEP 2
PRINT TAB(T); MID$ (A$,I,C)
C=C-2
T=T+1
NEXT I
END

vi)                CLS
LET A$=”PALPA”
C=1 : T=30
FOR I=5 TO 1 STEP -2
PRINT TAB(T); MID$ (A$,I,C)
C=C+2
T=T-1
NEXT I
END

vii)              CLS
LET A$=”PALPA”
PRINT MID$(A$,1,3);
END

viii)            CLS
LET A$=”PALPA”
FOR I = LEN(A$) TO 1 STEP -2
PRINT MID$(A$,I,1);
NEXT I
END

ix)                CLS
LET A$=”PALPA”
FOR I = 1 TO  LEN(A$) STEP 2
PRINT MID$(A$,I,1);
NEXT I
END

x)                  CLS
LET A$=”PALPA”
FOR I = LEN(A$) TO 1 STEP - 2
PRINT MID$(A$,I,1);
NEXT I
END





FILE HANDLING PROGRAMMING

58.            Write a program to create a serial file having variable length ecords of name, department and telephone number.

CLS
INPUT”Enter file name”;N$
OPEN N$ FOR OUTPUT AS # 1
INPUT”ENTER THE NAME”;NA$
INPUT”ENTER THE DEPARTMENT”;D$
INPUT”ENTER THE TELEPHONE”;T$
WRITE#1, NA$, D$, T$
CLOSE #1
END

59.             A data file “student.dat” contains records of students having the fields roll no, name , age and address. Write a program to read all the records and display.

OPEN “Student.dat” FOR INPUT AS #1
WHILE NOT EOF(1)
INPUT #1,R,N$,A,PH
PRINT “ROLL No”;R
PRINT “NAME”;N$
PRITN”AGE”;A
PRINT”PHONE”;PH
WEND
CLOSE #1

60.            Write a program a data file that stores name and marks of any three subjects of students. The program sould allow user to input records as needed.
OPEN “O”, #1, “Record.dat”

XYY:
INPUT”ENTER THE NAME”;N$
INPUT “ENTER THE MARKS OF MATH”;M
INPUT “ENTER THE MARKS OF SCIENCE”;S
INPUT “ENTER THE MARKS OF NEPALI”;L
WRITE #1, N$,M,S,L
INPUT”IS THERE NEXT RECORD”AN$
IF UCASE$(AN$)=”Y” THEN GOTO XYZ:
CLOSE #1
END

61.             Write a program to open a data file “RECORD.DAT” and add the records of next ten student. The file has fields name and marks of three subjects.
OPEN “A”, #1, “RECORD.DAT”
FOR I=1 TO 10
INPUT”ENTER THE NAEM”;N$
INPUT”ENTER THE MARKS OF MATH”;M
INPUT”ENTER THE MSRKS OF ENGLISH”;E
INPUT”ENTER THE MARKS OF NEPALI”;L
WRITE #1,N$,M,E,L
CLOSE #1
END

62.            Write a program to read all the records of “record.dat” data file and display the name, total marks and percentage marks of pass students. And also count total number o records of that file .
OPEN”I”,#1, “RECORD.DAT”
LET C=1
PRITN “NAME , TOTAL MARKS, PERCENTAGE”
DO
INPUT#1,N$,M,S,C
LET T=M+S+C
LET P=(T/3)*100
IF M>=40 AND S>=40 AND C>=40 THEN
PRINT N$,T,P
END IF
C=C+1
LOOP WHILE NOT EOF(1)
CLOSE#1
PRINT”TOTAL NUMBER OF RECORDS”;C
END

63.            WAP to read and display first 10 records of data file “EMP.dat”  having the fields  emp id , emp name, emp post and emp salary.
OPEN “I”,#1,”EMP.DAT”
PRINT “EMP ID, EMP NAME, POST, SALARY”
FOR I=1 TO 10
INPUT#1, ID, N$,P$,S
PRINT ID
PRINT N$
PRINT P$
PRINT S
NEXT I
CLOSE #1
END

64.            Write a program add new records in th exiting data file.
CLS
OPEN”STD.DAT” FOR APPEND AS #1
DO
INPUT”ENTER NAME”;N$
INPUT”ENTER ROLL NUMBER”;R
INPUT”ENTER CLASS”;C
WRITE #1,N$,R,C
CLOSE#1
END