QBASIC – Volume of a sphere

Table of Contents

Program

Below is the QBASIC program to calculate the volume of a sphere.

REM Program to find volume of sphere
CLS
INPUT "Enter the radius: "; r
volumen = 4/3 * 3.14 * r ^ 3
PRINT "Volume of a sphere is: ";volume
END

Output

Explanation

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

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