这应该是一个递归函数,当 i 小于 'h' 时,它不断向 'h' 添加 1/i 的值,但我在函数声明中不断收到冲突类型错误,我做错了什么?它只是发生在浮动中。
#include <stdio.h>
int main()
{
int i=0, n = 5;
float h;
division(i, n, h);
return 0;
}
float division(int i, int n, float h)
{
if(i<n)
{
h += 1/i;
division(i, n, h);
}
else
{
printf("the sum is: %f",h);
return h;
}
}
Run Code Online (Sandbox Code Playgroud) c floating-point runtime-error division function-declaration