C 两个双打怎么可能是冲突类型?

C 两个双打怎么可能是冲突类型?,c,C,您忘了为函数创建原型 将以下内容放在main函数之前(您也可以将整个函数移到main上方): 如果调用以前未定义或原型化的函数,编译器会假定它返回int——这与实际返回类型冲突。您可以将函数的原型放在main()之前,也可以将函数本身放在main()之前当编译器到达第15行时,它以前没有看到函数geom\u rec,因此它假设函数返回int 稍后,在第20行,您将函数定义为返回一个double并接受3个double参数,这与编译器对函数的“了解”不同。因此,它抱怨道,让你有机会在使用函数之前为函

您忘了为函数创建原型

将以下内容放在
main
函数之前(您也可以将整个函数移到
main
上方):


如果调用以前未定义或原型化的函数,编译器会假定它返回
int
——这与实际返回类型冲突。

您可以将函数的原型放在
main()
之前,也可以将函数本身放在
main()之前

当编译器到达第15行时,它以前没有看到函数
geom\u rec
,因此它假设函数返回
int


稍后,在第20行,您将函数定义为返回一个
double
并接受3个
double
参数,这与编译器对函数的“了解”不同。因此,它抱怨道,让你有机会在使用函数之前为函数定义一个合适的原型。

:p thx,我只是在课堂上学习,有时我会忘记这些事情。太多了!哎哟,这个答案的分数让我意识到它实际上让我的重复率增加了零:p@user1082764:请不要忘记。:)
#include<stdio.h>
#include<math.h>


int main(void){
  double a=0,r=0,n=0;
  printf("Enter Constant a:");
  scanf("%lf",&a);
  printf("Enter Constant r:");
  scanf("%lf",&r);
  printf("Enter Variable n:");
  scanf("%lf",&n);

  double an;
  an = geom_rec(a,r,n);    // Line 15

  return 0;
}

double geom_rec(double a,double r,double n){    // Line 20
  double ans=a;
  return a;
}
Line 20: error: conflicting types for 'geom_rec'
Line 15: error: previous implicit declaration of 'geom_rec' was here
double geom_rec(double a,double r,double n);