计算圆的周长和面积
使用工具:VS2017
功能:
1.输入一个圆的半径。
2.计算圆的周长和面积。
一、代码部分
函数实现:
#define PI 3.14
void perimeterAndArea(int r, float *l, float *s)
{
*l = (float)PI * 2 * r;
*s = (float)PI*r*r;
}
主函数调用:
int main()
{
int r; //圆的半径
float l, s; //圆的周长和面积
printf("输入圆的半径:\n");
scanf("%d", &r);
perimeterAndArea(r, &l, &s);
printf("圆的周长:%.2f\n", l);
printf("圆的面积:%.2f\n\n", s);
system("pause");
return 0;
}