我正在尝试编写一个程序来计算面积和体积以及给定数字的平均值。我成功地完成了这些但是当我尝试计算标准偏差时,我得到一个错误,我不知道如何解决,我无法甚至不明白是什么问题所以作为我的最后一招,我请求你们帮忙。谢谢这里是我的代码
#include <stdio.h>
#include <math.h>
int squaresarea(int edge)
{
int area = edge * edge;
printf ("Area of the square : %d\n",area);
return 0;
}
int rectanglesarea(int edge1,int edge2)
{
int rectanglesarea = edge1 * edge2;
printf ("Area of the rectangle : %d\n",rectanglesarea);
}
float spheresvolume(int radius)
{
float spheresvolume = (4.0/3)*M_PI*radius*radius*radius;
printf("Volume of the sphere: %f\n",spheresvolume);
}
float cylindersvolume(float radius1,float height)
{
float cylindersvolume = M_PI*radius1*radius1*height;
printf("Volume of the cylinder %f\n",cylindersvolume);
}
double average(float edge,float edge1,float edge2,float radius,float radius1,float height)
{
double average = (edge + edge1 + edge2 + radius + radius1 + height)/6;
printf("Average of the values entered: %f\n",average);
}
double standarddeviation(int edge,float average)
{
double standarddeviation = (edge - average);
}
int main (int edge,int edge1,int edge2,int radius,int radius1,int height)
{
printf("Enter the length of your square`s edge: ");
scanf("%d",&edge);
squaresarea(edge);
printf("Enter the lengths of your rectangles edges:");
scanf("%d %d",&edge1,&edge2);
rectanglesarea(edge1,edge2);
printf("Enter radius of your sphere: ");
scanf("%d",&radius);
spheresvolume(radius);
printf("Enter radius and height of your cylinder: ");
scanf("%d %d",&radius1,&height);
cylindersvolume(radius1,height);
average(edge,edge1,edge2,radius,radius1,height);
standarddeviation(edge,average);
return 0;
}
这是我得到的错误:
答案 0 :(得分:0)
standarddeviation()需要一个float值作为第二个参数,但是你传递了函数的名称 - avearge()。如果你想传递average()的返回值,你应该像这样使用standarddeviation(),
standarddeviation(edge, average(edge,edge1,edge2,radius,radius1,height));