小程序,哪里错了?
#include <stdio.h>#define PI 3.14159
main()
{
float circum,totalcost,no;
circum=area();
totalcost=cost(circum,cost,no);
printf("Total cost is %f\n",totalcost);
}
float area(float r, float h)
{
printf("Input Radius:");
scanf("%f",r);
printf("Input Height:");
scanf("%f",h);
printf("Circumference of a container is %f",PI*r*r+h*2*PI*r);
return(PI*r*r+h*2*PI*r);
}
float cost(float circum,float totalcost,float no)
{
printf("Input Quantity:");
scanf("%f",&no);
printf("Input cost per cm^2:");
scanf("%f",&cost);
printf("Cost of each container is %f\n",circum*cost);
totalcost=circum*cost*no;
return(totalcost);
}
定义两个函数,area涌来计算圆柱体的表面积,cost函数计算每个圆柱体的花费和总花费,
函数调用我不怎么熟悉,请问哪里错了?谢谢。