Question
The nth Fibonacci number is defined as the sum of the previous two Fibonacci numbers. The first and second Fibonacci numbers (which are needed to
The nth Fibonacci number is defined as the sum of the previous two Fibonacci numbers. The first and second Fibonacci numbers (which are needed to get the recurrence started) are 0 and 1, respectively. Write a function that takes a single argument, an int* that corresponds to an array of size (at least) 3. The precondition of the function is that the first two elements of the array are the (n-2) and (n-1) Fibonacci numbers.The function should compute the nth Fibonacci number and place it in the third element of the array.
Fill in the following main function so that it fills the first n Fibonacci numbers into the fib array. Use the function you defined above to compute each number.
int main(){
const int n = 25;
int fib[n];
int i;
fib[0] = 0;
fib[1] = 1; /* fill this in */
}
I have so far:
#include
How do I make a seperate function fib() and how to implement pointers?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started