1 of 9

SEE Computer

Modular Programming 4 mark

पुरुषोत्तम लाल कर्ण

1

2 of 9

  1. Write a program in QBASIC that asks length, breadth and height of room and calculates its area and volume. Create a user-defined function to calculate area and sub-program to calculate volume. Hint: [A=L x B], [V=L x B x H]. CDC Model Set 077

DECLARE FUNCTION AREA(L,B)

DECLARE SUB VOLUME(L,B,H)

INPUT " Enter L, B and H value ";L,B,H

PRINT " Area is ";AREA(L,B)

CALL VOLUME(L,B,H)

END

FUNCTION AREA(L,B)

AREA = L * B

END FUNCTION

SUB VOLUME(L,B,H)

V = L * B * H

PRINT " Volume is " ;V

END SUB

2

3 of 9

2. Write a program in QBASIC that asks length, breadth of a room and calculate its area and perimeter. Create a user defined function to calculate area and sub program to calculate perimeter.

[Hint: [Area=LxB], [p=2(L+B]] SEE 2078 (2022)

DECLARE FUNCTION AREA(L,B)

DECLARE SUB PERI(L,B)

INPUT " Enter L and B value ";L,B

PRINT " Area is ";AREA(L,B)

CALL PERI(L,B)

END

FUNCTION AREA(L,B)

AREA = L * B

END FUNCTION

SUB PERI(L,B)

P = 2 * (L + B)

PRINT " Perimeter is " ;P

END SUB

3

4 of 9

3. Write a program in QBASIC that asks radius of a circle to calculate its area and circumference. Create a user-defined function to calculate area and sub-program to calculate circumference.

[Hint: A=πr2 C=2πr] SEE 2079 (2023)

DECLARE FUNCTION AREA(R)

DECLARE SUB CIR(R)

INPUT "Enter r value "; AREA(R)

PRINT " Area is "; AREA(R)

CALL CIR(R)

END

FUNCTION AREA(R)

AREA = 3.14 * R ^ 2

END FUNCTION

SUB CIR(R)

C = 2 * 3.14 * R

PRINT "Circumference is ";C

END SUB

4

5 of 9

4. Write a program in QBASIC to calculate total surface area of a cylinder using function procedure and volume using sub procedure.

[Area=Total surface area=2ℼr(r+h) and volume=ℼr2h]

SEE Pre Qualify 2079

DECLARE FUNCTION TSA(R,H)

DECLARE SUB VOL(R)

INPUT "Enter R and H value ";R,H

PRINT " Total Surface Area is "; TSA(R,H)

CALL VOL(R,H)

END

FUNCTION TSA(R,H)

TSA = 2 * 3.14 * R * (R + H)

END FUNCTION

SUB VOL(R,H)

V = 3.14 * R ^ 2 * H

PRINT "Volume is ";V

END SUB

5

6 of 9

5. Write a program in QBASIC that ask the radius of circle. Write a program to calculate the area and circumference of a circle. Create a user defined function first (r) to calculate area and sub procedure second (r) to calculate circumference of a circle. PABSON Board Set B - 2078 (2022)

DECLARE FUNCTION first(r)

DECLARE SUB second(r)

INPUT "Enter R value ";r

PRINT " Area is "; first(r)

CALL second(r)

END

FUNCTION first(r)

first=3.14*r*r

END FUNCTION

SUB second(r)

C = 2 *3.14* r

PRINT "Circumference is ";C

END SUB

6

7 of 9

6.Write a program in QBASIC that asks length, breadth and height of room and calculate its area and volume. Create a User Defined Function to calculate Area and Sub Program to calculate the Volume. [Hint: Area=L×B and Volume=L×B×H] SEE 2080 Regular

DECLARE FUNCTION area(L,B)

DECLARE SUB volume(L,B,H)

INPUT "Enter L,B and H value " ; L,B,H

PRINT " Area is "; area(L,B)

CALL volume(L,B)

END

FUNCTION area(L,B)

area=L*B

END FUNCTION

SUB volume(L,B,H)

V = L * B * H

PRINT " Volume is " ; V

END SUB

7

8 of 9

7. Write a program in QBASIC that asks radius and height of a cylinder. Create a user defined function to calculate total surface area and a sub program to calculate the volume of cylinder. [Hint : TSA=2*𝜫*r(r+h) and volume=𝜫*r2*h] SEE 2080 Grade Improvement Exam

DECLARE FUNCTION TSA(R,H)

DECLARE SUB VOL(R)

INPUT "Enter R and H value ";R,H

PRINT " Total Surface Area is "; TSA(R,H)

CALL VOL(R,H)

END

FUNCTION TSA(R,H)

TSA = 2 * 3.14 * R * (R + H)

END FUNCTION

SUB VOL(R,H)

V = 3.14 * R ^ 2 * H

PRINT "Volume is ";V

END SUB

8

9 of 9

8. Write a program in QBASIC that asks radius and height of a cylinder. Create a user defined function to calculate total surface area and a sub program to calculate the volume of cylinder. [Hint : TSA=2*𝜫*r(r+h) and volume=𝜫*r2*h] SEE 2080 Grade Improvement Exam

DECLARE FUNCTION TSA(R,H)

DECLARE SUB VOL(R)

INPUT "Enter R and H value ";R,H

PRINT " Total Surface Area is "; TSA(R,H)

CALL VOL(R,H)

END

FUNCTION TSA(R,H)

TSA = 2 * 3.14 * R * (R + H)

END FUNCTION

SUB VOL(R,H)

V = 3.14 * R ^ 2 * H

PRINT "Volume is ";V

END SUB

9