QBASIC – Volume of a cylinder

Table of Contents

Program

Below is the QBASIC program to calculate the volume of a cylinder

REM Program to find volume of cylinder
CLS
INPUT "Enter the radius: "; r
INPUT "Enter the height: "; h
volume = 3.14 * r ^ 2 * h
PRINT "Volume of a cylinder is: ";volume
END

Output

Explanation

Let’s first see the formula:  volume = pi * r ^ 2 * h, where the value of pi is 3.14. So, we can determine the volume of any cylinder by taking the radius and height of the cylinder from the user and multiplying the value of pi by the radius raised to the power of 2, and the height.

More Programs

https://thinkshare.one/learn/programming/qbasic/

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version