QBasic Programming

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

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

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!