Question: Use C++ 2.(Fibonacci Series) (50 points) Modify a program generating a Fibonacci series (Program 3 from the Homework1) in the following way. The Fibonacci series
2.(Fibonacci Series) (50 points) Modify a program generating a Fibonacci series (Program 3 from the Homework1) in the following way. The Fibonacci series shall be generated in the function int EibGsp(int ptrl, int ptr2) where ptrl is a pointer to the 1t member of the series and ptr2 is a pointer to the 2nd member of the series. A series generated in the function shall be located in the dynamical array and return a pointer to this array to a calling program. The (0h) element of this array shall be reserved for the number of the series members generated, the series members shall be located starting from the (1) element of the resulting array The series members shall be generated until the ratio of adjacent values converges to the golden section within 0.001, which means that the process should be stopped when the following condition holds s0.001 where xi,x2,K,.-4-2,&q,,,, is a Fibonacci series. Test this function by writing a main function which shall a) prompt the user to enter two first members of the series and accept them; b) pass pointers to the members entered to the EibSso function; c accept a returned dynamical array from the EibGso function; d) display the number of the series members generated (0h element of the array) and the series members. (Hint: First use a while loop to calculate how many elements a Fibonacci series should contain based on the values of first two elements and the criterion above. Then create a dynamical array containing exactly that number of elements, which was found in the while loop and use a for loop to finally generate a Fibonacci series and put its elements in the dynamical array.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
