QBasic Programming

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

Display volume of sphere (Prev Lesson)
(Next Lesson) Display total surface area of hemisphere
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!