gpt4 book ai didi

c - Ubuntu C 编程预期为浮点型,但参数为 double * 类型

转载 作者:行者123 更新时间:2023-11-30 19:37:27 25 4
gpt4 key购买 nike

我正在尝试编写一个程序来计算面积和体积以及给定数字的平均值。我成功地做到了这些,但是当我尝试计算标准差时,我得到了一个错误,我不知道如何解决,我无法解决`甚至不明白问题是什么所以作为我最后的手段,我请求你们帮忙。谢谢这是我的代码

#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;
}

这是我得到的错误:

Error message screenshot

最佳答案

standarddeviation() 需要一个浮点值作为第二个参数,但您传递了函数的名称 - avearge()。如果你想传递average()的返回值,你应该像这样使用standarddeviation(),

standarddeviation(edge, average(edge,edge1,edge2,radius,radius1,height));

关于c - Ubuntu C 编程预期为浮点型,但参数为 double * 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39805512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com