I have an assignment to work on that I am not sure how to complete, and the instructor isn't giving me any help to explain what exactly he wants(frustrating). Essentially I am asking for some of your help to see how you would tackle this program. I need to write a program that reads an integer number from a data file, and calculates the Fibonacci number of that number, and prints the number and corresponding Fibonacci number, then repeat this process until it reaches the end of data file, also I need a recursive version and non recursive version for the program. I have written the code that takes the users filename and displays the contents of the file, I am just wondering how to do the recursion calculation for the Fib. numbers. Thanks for any and all help on this one. Here is the code I have for user input.
I have now written the functions for the recursive and non recursive functions to return the corresponding Fib. numbers, my question now is how do I get the input to go into the functions and return the Fib. number?
int nonRecursiveFib(int n)
{
int a = 0;
int b = 1;
int c;
int i;
if (n == 0)
{
return a;
}
for (i = 2; i <= n; i++)
{
c = a + b;
a = b;
b = c;
}
return b;
}