C语言求解计算半圆弧的周长及半圆面积?

2024-12-04 09:54:40
推荐回答(2个)
回答1:

不好意思,我不知道什么叫宏常量,我试着编了一下,您看看

#include
int main() {
double r =5.3;
double a =3.14159;
printf ("Area=%f\n",(long)a*r*r);
printf ("circumference=%f\n",2*a*r);
}

回答2:

#define r = 5.3;
#define PI = 3.14159;
int main()
{
float Area = PI*r*r/2;
float circumference = PI*r+2*r;
printf("%f,%f",Area,circumference);
return 0;
}