c语言使用宏定义π的值,输入球的半径,输出球的表面积和体积
时间: 2024-05-25 16:15:49 浏览: 100
#include <stdio.h>
#define PI 3.14159
int main()
{
double radius, volume, surface_area;
printf("Enter the radius of the sphere: ");
scanf("%lf", &radius);
volume = (4.0/3.0) * PI * radius * radius * radius;
surface_area = 4.0 * PI * radius * radius;
printf("The volume of the sphere is %lf\n", volume);
printf("The surface area of the sphere is %lf\n", surface_area);
return 0;
}
阅读全文