I am having a problem with a program I have written, the requirements were to
"Write a function that computes and returns the n-th Fibonacci number. The main should invoke that function and print out the 10, 20, and 30th Fibonacci numbers. Consider that the first two numbers are 0 and 1."
I'm not sure what I'm doing wrong, and any suggestions would be appreciated!!!
"Write a function that computes and returns the n-th Fibonacci number. The main should invoke that function and print out the 10, 20, and 30th Fibonacci numbers. Consider that the first two numbers are 0 and 1."
I'm not sure what I'm doing wrong, and any suggestions would be appreciated!!!
Code:
#include <stdio.h>
int funcfib(int n1);
int main( )
{
int n;
funcfib ( n );
}
int funcfib (int n1)
{
int answer;
printf ( "Enter number to find, enter 0 to exit: ");
scanf ("%d", &n1);
if (n1 > 0){
if ( n1 < 3 )
return (1);
else
return( funcfib(n1-2) + funcfib(n1-1));
}
answer = funcfib (n1);
printf ("\n\n");
printf (" %dth Fibonacci Number is %d\n", n1, answer);
}
Comment