用c语言计算球体的体积和表面积
时间: 2024-05-22 17:16:53 浏览: 117
用C语言来计算球的体积.c
#include <stdio.h>
#define PI 3.1415926535
int main()
{
float radius, volume, surface_area;
printf("Enter the radius of the sphere: ");
scanf("%f", &radius);
volume = (4.0/3) * PI * radius * radius * radius;
surface_area = 4 * PI * radius * radius;
printf("The volume of the sphere is: %.2f\n", volume);
printf("The surface area of the sphere is: %.2f\n", surface_area);
return 0;
}
阅读全文