C中递归函数的隐式声明

时间:2014-09-28 12:04:17

标签: c algorithm recursion

我必须使用递归函数来评估此分数,其中" n"是分数的计数

enter image description here

但我得到了这个错误:"隐含的功能声明"和#34;冲突类型"

#include <stdlib.h>
#include <stdio.h>

int main(void) {

    printf("Enter size of n\n");
    int n;
    scanf ("%d", &n);

    float result = 2 / recursion(n); //implicit declaration of function
    printf("Result of dividing is = %f", result);

    return 0;
}

float recursion(int n) { //conflicting types

    float res = 2 + recursion(n - 1);

    return res;
}

帮助我找出它的错误

0 个答案:

没有答案