2025-03-06 22:46:33 +08:00

25 lines
555 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
功能输入一个圆半径r当r>0时计算并输出圆的面积(area)和周长(circumference),否则,输出提示信息。
--------------------------------------------------------*/
#include <stdio.h>
#define PI 3.14
main()
{
float r,s,l;
printf("please input r:\n");
scanf("%f",&r);
if (r>=0)
{
/**********Program**********/
s = PI * r*r;
l = 2*PI*r;
/********** End **********/
printf("the area is %f\n",s);
printf("the circumference is %f\n",l);
}
else
printf("input error!\n");
}