#include
#define Pi 3.14159
double Square(double r){
return Pi * r * r;
}
double Perimeter(double r){
return 2 * Pi * r;
}
int main(){
double r;
printf("请输入圆的半径:\n");
while(scanf("%lf",&r)!= EOF){
printf("圆的面积是%lf\n",Square(r));
printf("圆的周长是%lf\n",Perimeter(r));
printf("请输入圆的半径:\n");
}
return 0;
}
运行结果:
请输入圆的半径:
1
圆的面积是3.141590
圆的周长是6.283180
请输入圆的半径:
2
圆的面积是12.566360
圆的周长是12.566360
请输入圆的半径: