Modular programming solutions for SEE class 10 Computer Science. Program to create user defined function and sub module. Four marks question is always asked in SEE class 10 computer regarding function and sub procedure. Following are some important program solution according to new specification grid for SEE.
Q No. 1) Write a QBASIC program to input two numbers and calculate their product using function and their sum using sub procedure.
Declare function pro(a, b)
Declare sub sum(a, b)
Cls
Input “Enter two number”; a, b
x = pro(a, b)
Print “Product is”; x
Call sum(a, b)
End
Function pro(a, b)
P = a*b
Pro = p
End function
Sub sum(a, b)
S = a+b
Print “Sum is “; S
End sub
Q No. 2) Write a QBASIC program to input length, breadth and height of a box and calculate its volume [v=lbh] using function and its area of four walls [a=2h(l+b)] using sub procedure.
Declare function vol(l, b, h)
Declare sub area(l, b, h)
Cls
Input “Enter length breadth and height number”; l, b, h
x = vol(l, b, h)
Print “Volume is”; x
Call area(l, b, h)
End
Function vol(l, b, h)
v = l*b*h
Vol = v
End function
Sub area(l, b, h)
A = 2*h*(l+b)
Print “Area is “; A
End sub
Q No. 3) Write a QBASIC program to input radius of a circle and calculate its area [a=πr2] using function and circumference [c=2πr] using sub procedure.
Declare function area(r)
Declare sub circum(r)
Cls
Input “Enter radius”; r
x = area(r)
Print “Area is”; x
Call circum(r)
End
Function area(r)
a = 3.14*r*r
Area = a
End function
Sub circum(r)
C = 2*3.14*r
Print “Circumference is “; C
End sub
Q.No. 4) Write a QBASIC program to input radius and height of a cylinder and calculate its volume [v=πr2h] using function and its curved surface area [csa=2πrh] using sub procedure.
Declare function vol(r, h)
Declare sub csa(r, h)
Cls
Input “Enter radius and height number”; r, h
x = vol(r, h)
Print “Volume is”; x
Call csa(r, h)
End
Function vol(r, h)
v = 3.14*r*r*h
Vol = v
End function
Sub csa(r, h)
A = 2*3.14*r*h
Print “Area is “; A
End sub
Click here for full New course note of Class 10 Computer Science.