Current location - Training Enrollment Network - Mathematics courses - Calculation of frustum volume with C language
Calculation of frustum volume with C language
1. Let's start with the definition of the function. The functions in C language are similar to those in mathematics, but they are different. It is necessary to define a tiji () function.

2. This function has a return value. To return the calculated volume, the return value is decimal, so the return value type is defined as double;;

3. Transfer of function language parameters. Language conveys the radius of the circle at the bottom of the cylinder and the height of the cylinder, which is called the double-body basis (double R, double H).

4. Don't forget to declare the function before writing the main function. If you don't declare the system, you can't find the defined function.

5. Complete the main function, define variables, input variables and let the system calculate the volume of the cylinder;

6. Finally, output the calculation results and print them on the screen, thus completing a simple program. Note that the input format is% if.