这是计算园的面积,但是有错误,#define PI 3.1415; void ys(); {float r; float s; scanf("%d",&r); s=pi*r*r; printf ("ys=%7.3f\n",s); }这是一个计算园的面积的函数,但是在运行的时候有错误,本人实在是不知道哪里出
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/30 10:10:53
![这是计算园的面积,但是有错误,#define PI 3.1415; void ys(); {float r; float s; scanf(](/uploads/image/z/11576213-53-3.jpg?t=%E8%BF%99%E6%98%AF%E8%AE%A1%E7%AE%97%E5%9B%AD%E7%9A%84%E9%9D%A2%E7%A7%AF%2C%E4%BD%86%E6%98%AF%E6%9C%89%E9%94%99%E8%AF%AF%2C%23define+PI+3.1415%3B+void+ys%28%29%3B+%7Bfloat+r%3B+float+s%3B+scanf%28%22%25d%22%2C%26r%29%3B+s%3Dpi%2Ar%2Ar%3B+printf+%28%22ys%3D%257.3f%5Cn%22%2Cs%29%3B+%7D%E8%BF%99%E6%98%AF%E4%B8%80%E4%B8%AA%E8%AE%A1%E7%AE%97%E5%9B%AD%E7%9A%84%E9%9D%A2%E7%A7%AF%E7%9A%84%E5%87%BD%E6%95%B0%2C%E4%BD%86%E6%98%AF%E5%9C%A8%E8%BF%90%E8%A1%8C%E7%9A%84%E6%97%B6%E5%80%99%E6%9C%89%E9%94%99%E8%AF%AF%2C%E6%9C%AC%E4%BA%BA%E5%AE%9E%E5%9C%A8%E6%98%AF%E4%B8%8D%E7%9F%A5%E9%81%93%E5%93%AA%E9%87%8C%E5%87%BA)
这是计算园的面积,但是有错误,#define PI 3.1415; void ys(); {float r; float s; scanf("%d",&r); s=pi*r*r; printf ("ys=%7.3f\n",s); }这是一个计算园的面积的函数,但是在运行的时候有错误,本人实在是不知道哪里出
这是计算园的面积,但是有错误,
#define PI 3.1415; void ys(); {float r; float s; scanf("%d",&r); s=pi*r*r; printf ("ys=%7.3f\n",s); }
这是一个计算园的面积的函数,但是在运行的时候有错误,本人实在是不知道哪里出错,
这是计算园的面积,但是有错误,#define PI 3.1415; void ys(); {float r; float s; scanf("%d",&r); s=pi*r*r; printf ("ys=%7.3f\n",s); }这是一个计算园的面积的函数,但是在运行的时候有错误,本人实在是不知道哪里出
#define PI 3.1415; //-------------->>>这里不能加分号“;”
void ys(); //--------------->>>>这里也不能加分号
{
float r;
float s;
scanf("%d",&r); //-------------->>>这里应该用%f,因为输入的是浮点数
s=pi*r*r; //-------------->>>这里应该是大写PI,C语言十大小写敏感的
printf ("ys=%7.3f\n",s);
}
正确的写法应该是:
#define PI 3.1415
void ys()
{
float r;
float s;
scanf("%f",&r);
s=PI*r*r;
printf ("ys=%7.3f\n",s);
}