QBASIC PROGRAM DISPLAY VOLUME OF CYLINDER
Solution
Display the volume of a 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
DISPLAY VOLUME OF CYLINDER 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
DISPLAY VOLUME OF CYLINDER 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