Saturday, October 22, 2016

Qbasic Program: Volume of sphere



31. Display total surface area of sphere.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF SPHERE.
CLS
INPUT “ENTER RADIUS ”; R
A= 4 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF SPHERE “; A
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (R)
CLS
INPUT “ENTER RADIUS”; R
CALL TSAREA(R)
END

SUB TSAREA (R)
A= 4 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF SPHERE “; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “TOTAL SURFACE AREA OF SPHERE ”; TSAREA(R)
END

FUNCTION TSAREA (R)
TSAREA = 4 * 3.14 * R ^ 2
END FUNCTION










32. Display volume of sphere.

REM PROGRAM TO DISPLAY VOLUME OF SPHERE.
CLS
INPUT “ENTER RADIUS ”; R
V = (4 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF SPHERE ”; V
END

USING SUB PROCEDURE

DECLARE SUB VOLUME(R)
CLS
INPUT “ENTER RADIUS”; R
CALL VOLUME(R)
END

SUB VOLUME (R)
V = (4 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF SPHERE ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION VOLUME (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “VOLUME OF SPHERE ”; VOLUME(R)
END

FUNCTION VOLUME (R)
VOLUME = (4 / 3) * 3.14 * R ^ 3
END FUNCTION










33. Display total surface area and volume of sphere.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA AND VOLUME OF SPHERE.
CLS
INPUT “ENTER RADIUS ”; R
A= 4 * 3.14 * R ^ 2
V = (4 / 3) * 3.14 * R ^ 3
PRINT “TOTAL SURFACE AREA OF SPHERE “; A
PRINT “VOLUME OF SPHERE ”; V
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (R)
DECLARE SUB VOLUME(R)
CLS
INPUT “ENTER RADIUS”; R
CALL TSAREA(R)
CALL VOLUME(R)
END

SUB TSAREA (R)
A= 4 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF SPHERE “; A
END SUB

SUB VOLUME (R)
V = (4 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF SPHERE ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (R)
DECLARE FUNCTION VOLUME (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “TOTAL SURFACE AREA OF SPHERE ”; TSAREA(R)
PRINT “VOLUME OF SPHERE ”; VOLUME(R)
END

FUNCTION TSAREA (R)
TSAREA = 4 * 3.14 * R ^ 2
END FUNCTION

FUNCTION VOLUME (R)
VOLUME = (4 / 3) * 3.14 * R ^ 3
END FUNCTION

34. Display total surface area of hemisphere.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF HEMISPHERE.
CLS
INPUT “ENTER RADIUS ”; R
A= 3 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF HEMISPHERE “; A
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (R)
CLS
INPUT “ENTER RADIUS”; R
CALL TSAREA(R)
END

SUB TSAREA (R)
A= 3 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF HEMISPHERE “; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “TOTAL SURFACE AREA OF HEMISPHERE ”; TSAREA(R)
END

FUNCTION TSAREA (R)
TSAREA = 3 * 3.14 * R ^ 2
END FUNCTION

35. Display volume of hemisphere.

REM PROGRAM TO DISPLAY VOLUME OF HEMISPHERE.
CLS
INPUT “ENTER RADIUS ”; R
V = (2 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF HEMISPHERE ”; V
END

USING SUB PROCEDURE

DECLARE SUB VOLUME(R)
CLS
INPUT “ENTER RADIUS”; R
CALL VOLUME(R)
END

SUB VOLUME (R)
V = (2 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF HEMISPHERE ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION VOLUME (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “VOLUME OF HEMISPHERE ”; VOLUME(R)
END

FUNCTION VOLUME (R)
VOLUME = (2 / 3) * 3.14 * R ^ 3
END FUNCTION


36. Display total surface area and volume of hemisphere.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA AND VOLUME OF HEMISPHERE.
CLS
INPUT “ENTER RADIUS ”; R
A= 3 * 3.14 * R ^ 2
V = (2 / 3) * 3.14 * R ^ 3
PRINT “TOTAL SURFACE AREA OF HEMISPHERE “; A
PRINT “VOLUME OF HEMISPHERE ”; V
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (R)
DECLARE SUB VOLUME(R)
CLS
INPUT “ENTER RADIUS”; R
CALL TSAREA(R)
CALL VOLUME(R)
END

SUB TSAREA (R)
A= 3 * 3.14 * R ^ 2
PRINT “TOTAL SURFACE AREA OF HEMISPHERE “; A
END SUB

SUB VOLUME (R)
V = (2 / 3) * 3.14 * R ^ 3
PRINT “VOLUME OF HEMISPHERE ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (R)
DECLARE FUNCTION VOLUME (R)
CLS
INPUT “ENTER RADIUS”; R
PRINT “TOTAL SURFACE AREA OF HEMISPHERE ”; TSAREA(R)
PRINT “VOLUME OF HEMISPHERE ”; VOLUME(R)
END

FUNCTION TSAREA (R)
TSAREA = 3 * 3.14 * R ^ 2
END FUNCTION

FUNCTION VOLUME (R)
VOLUME = (2 / 3) * 3.14 * R ^ 3
END FUNCTION

37. Display total surface area of cylinder.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF CYLINDER
CLS
INPUT “ENTER RADIUS ”; R
INPUT “ENTER HEIGHT”; H
A= 2 * 3.14 * R * (R + H)
PRINT “TOTAL SURFACE AREA OF CYLINDER “; A
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
CALL TSAREA(R, H)
END

SUB TSAREA (R, H)
A= 2 * 3.14 * R * (R + H)
PRINT “TOTAL SURFACE AREA OF CYLINDER “; A
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
PRINT “TOTAL SURFACE AREA OF CYLINDER”; TSAREA(R, H)
END

FUNCTION TSAREA (R, H)
TSAREA = 2 * 3.14 * R * (R + H)
END FUNCTION



38. Display volume of cylinder.

REM PROGRAM TO DISPLAY VOLUME OF CYLINDER.
CLS
INPUT “ENTER RADIUS ”; R
INPUT “ENTER HEIGHT”; H
V = 3.14 * R ^ 2 * H
PRINT “VOLUME OF CYLINDER ”; V
END

USING SUB PROCEDURE

DECLARE SUB VOLUME(R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
CALL VOLUME(R, H)
END

SUB VOLUME (R, H)
V = 3.14 * R ^ 2 * H
PRINT “VOLUME OF CYLINDER ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION VOLUME (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
PRINT “VOLUME OF CYLINDER ”; VOLUME(R, H)
END

FUNCTION VOLUME (R, H)
VOLUME = 3.14 * R ^ 2 * H
END FUNCTION







39. Display total surface area and volume of cylinder.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA AND VOLUME OF CYLINDER
CLS
INPUT “ENTER RADIUS ”; R
INPUT “ENTER HEIGHT”; H
A= 2 * 3.14 * R * (R + H)
V = 3.14 * R ^ 2 * H
PRINT “TOTAL SURFACE AREA OF CYLINDER “; A
PRINT “VOLUME OF CYLINDER ”; V
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (R, H)
DECLARE SUB VOLUME(R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
CALL TSAREA(R, H)
CALL VOLUME(R, H)
END

SUB TSAREA (R, H)
A= 2 * 3.14 * R * (R + H)
PRINT “TOTAL SURFACE AREA OF CYLINDER “; A
END SUB

SUB VOLUME (R, H)
V = 3.14 * R ^ 2 * H
PRINT “VOLUME OF CYLINDER ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (R, H)
DECLARE FUNCTION VOLUME (R, H)
CLS
INPUT “ENTER RADIUS”; R
INPUT “ENTER HEIGHT”; H
PRINT “TOTAL SURFACE AREA OF CYLINDER ”; TSAREA(R, H)
PRINT “VOLUME OF CYLINDER ”; VOLUME(R, H)
END

FUNCTION TSAREA (R, H)
TSAREA = 2 * 3.14 * R * (R + H)
END FUNCTION

FUNCTION VOLUME (R, H)
VOLUME = 3.14 * R ^ 2 * H
END FUNCTION


40. Display total surface area of cuboid / box.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF CUBOID / BOX
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
T= 2 * (L * B + B * H + H * L)
PRINT “TOTAL SURFACE AREA OF CUBOID“; T
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL TSAREA(L, B, H)
END

SUB TSAREA (L, B, H)
T= 2 * (L * B + B * H + H * L)
PRINT “TOTAL SURFACE AREA OF CUBOID “; T
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
PRINT “TOTAL SURFACE AREA OF CUBOID”; TSAREA(L, B, H)
END

FUNCTION TSAREA (L, B, H)
TSAREA = 2 * (L * B + B * H + H * L)
END FUNCTION

41. Display volume of cuboid / box.

REM PROGRAM TO DISPLAY VOLUME OF CUBOID.
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
V = L * B * H
PRINT “VOLUME OF CUBOID ”; V
END

USING SUB PROCEDURE

DECLARE SUB VOLUME(L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL VOLUME(L, B, H)
END

SUB VOLUME (L, B, H)
V = L * B* H
PRINT “VOLUME OF CUBOID ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION VOLUME (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
PRINT “VOLUME OF CUBOID  ”; VOLUME(L, B, H)
END

FUNCTION VOLUME (L, B, H)
VOLUME = L * B * H
END FUNCTION


42. Display total surface area and volume of cuboid.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA AND VOLUME OF CUBOID
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
A= 2 * (L * B + B * H + H * L)
V = L * B * H
PRINT “TOTAL SURFACE AREA OF CUBOID “; A
PRINT “VOLUME OF CUBOID ”; V
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (L, B, H)
DECLARE SUB VOLUME(L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
CALL TSAREA(L, B, H)
CALL VOLUME(L, B, H)
END

SUB TSAREA (L, B, H)
A= 2 * (L * B + B * H + H * L)
PRINT “TOTAL SURFACE AREA OF CUBOID “; A
END SUB

SUB VOLUME (L, B, H)
V = L * B * H
PRINT “VOLUME OF CUBOID ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (L, B, H)
DECLARE FUNCTION VOLUME (L, B, H)
CLS
INPUT “ENTER LENGTH”; L
INPUT “ENTER BREADTH”; B
INPUT “ENTER HEIGHT”; H
PRINT “TOTAL SURFACE AREA OF CUBOID ”; TSAREA(L, B, H)
PRINT “VOLUME OF CUBOID ”; VOLUME(L, B, H)
END

FUNCTION TSAREA (L, B, H)
TSAREA = 2 * (L * B + B * H + H * L)
END FUNCTION

FUNCTION VOLUME (L, B, H)
VOLUME = L * B * H
END FUNCTION


43. Display total surface area of cube.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA OF CUBE
CLS
INPUT “ENTER SIDE OF A CUBE”; L
T= 6 * L ^ 2
PRINT “TOTAL SURFACE AREA OF CUBE“; T
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (L)
CLS
INPUT “ENTER SIDE OF A CUBE”; L
CALL TSAREA(L)
END

SUB TSAREA (L)
T= 6 * L ^ 2
PRINT “TOTAL SURFACE AREA OF CUBE “; T
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (L)
CLS
INPUT “ENTER LENGTH”; L
PRINT “TOTAL SURFACE AREA OF CUBE”; TSAREA(L)
END

FUNCTION TSAREA (L)
TSAREA = 6 * L ^ 2
END FUNCTION

44. Display volume of cube

REM PROGRAM TO DISPLAY VOLUME OF CUBE
CLS
INPUT “ENTER LENGTH”; L
V = L ^ 3
PRINT “VOLUME OF CUBE ”; V
END

USING SUB PROCEDURE

DECLARE SUB VOLUME(L)
CLS
INPUT “ENTER LENGTH”; L
CALL VOLUME(L)
END

SUB VOLUME (L)
V = L ^ 3
PRINT “VOLUME OF CUBE ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION VOLUME (L)
CLS
INPUT “ENTER LENGTH”; L
PRINT “VOLUME OF CUBE  ”; VOLUME(L)
END

FUNCTION VOLUME (L)
VOLUME = L ^ 3
END FUNCTION


45. Display total surface area and volume of cube.

REM PROGRAM TO DISPLAY TOTAL SURFACE AREA AND VOLUME OF CUBE
CLS
INPUT “ENTER LENGTH”; L
A= 6 * L ^ 2
V = L ^ 3
PRINT “TOTAL SURFACE AREA OF CUBE “; A
PRINT “VOLUME OF CUBE ”; V
END

USING SUB PROCEDURE

DECLARE SUB TSAREA (L)
DECLARE SUB VOLUME(L)
CLS
INPUT “ENTER LENGTH”; L
CALL TSAREA(L)
CALL VOLUME(L)
END

SUB TSAREA (L)
A= 6 * L ^ 2
PRINT “TOTAL SURFACE AREA OF CUBE “; A
END SUB

SUB VOLUME (L)
V = L ^ 3
PRINT “VOLUME OF CUBE ”; V
END SUB


USING FUNCTION PROCEDURE

DECLARE FUNCTION TSAREA (L)
DECLARE FUNCTION VOLUME (L)
CLS
INPUT “ENTER LENGTH”; L
PRINT “TOTAL SURFACE AREA OF CUBE ”; TSAREA(L)
PRINT “VOLUME OF CUBE  ”; VOLUME(L)
END

FUNCTION TSAREA (L)
TSAREA = 6 * L ^ 2
END FUNCTION

FUNCTION VOLUME (L)
VOLUME = L ^ 3
END FUNCTION





No comments:

Post a Comment