I'm trying to write a C program that outputs the fibonacci numbers using an iterative function. I want to use an array which containing the Fibonacci numbers
The program gives me the wrong fibonacci values, I cannot see any mistake
Please help
here is my programm:
#include <stdio.h>
int fibonacciL(int unsigned value){
int i;
const int MAX = value;
int fibo[MAX];
fibo[0]=0;
fibo[1]=1;
for(i=2;i<value+1;i++)
{
fibo[i]= fibo[i-1] + fibo[i-2];
return fibo[value];
}
}
int main(){
int value;
printf("Iterativ Fibonacci
");
printf("Enter a Number:");
scanf("%d", &value);
printf("For the number %d the value is: %d
",value,fibonacciL(value));
return 0;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…