In C language, the volume expression formula of the ball is volume = (4/3) PI radius^3, where radius is the radius of the ball and PI is the pi constant (approximately 3.14159265).
The volume of the ball in C language is expressed
In C language, the volume of the ball can be expressed by the following formula :
<code class="c">volume = (4/3) * PI * radius^3</code>
Where:
volume
:The volume of the ballradius
:The radius of the ballPI
: Pi is a constant about 3.14159265, which can be defined by #define PI 3.14159265
Example:
Suppose there is a sphere with a radius of 5, its volume can be calculated as follows:
<code class="c">#include <stdio.h> #define PI 3.14159265 int main() { float radius = 5; float volume = (4/3) * PI * radius * radius * radius; printf("球的体积为:%.2f\n", volume); return 0; }</code>
Run this program, the following output will be printed:
<code>球的体积为:523.60</code>
The above is the detailed content of How to express the volume of a ball in C language. For more information, please follow other related articles on the PHP Chinese website!