我用 C 语言编写了一个代码,它适用于 int,但是当我尝试使用 float 执行此操作时,它显示错误我该怎么做才能使其正确。
#include<stdio.h>
int main()
{
float a,y;
float square();
scanf("%f", &a);
y = square( a );
printf("%f %f ",a ,y);
}
float square(float b)
{
float z;
z = b*b;
printf("%f %f",z ,b);
return(z);
}
错误:
return.c:12: error: conflicting types for 'square'
return.c:13: note: an argument type that has a default promotion can't match an empty parameter name list declaration
return.c:6: note: previous declaration of 'square' was here