Iterative Fibonacci (while loop, perils of integer arithmetic) The Fibonacci sequence defined by F=1,1,2, 3, 5, 8, 13, 21, 34, 55, 89, ... where the 4th term is given by F₁ = F₁-1+Fx-2 As k increases, the ratio of two adjacent terms in the sequence approaches the Golden Ratio, F₂ =drp. The goal of this problem is to generate Fibonacci numbers until the absolute value of the difference between subsequent computations of the Golden Ratio falls below a given tolerance. My Solutions E = |x-₁-1- Code has already been provided to define a function named fibGenerator that accepts a single input value into the variable to1GR. Add code that uses a while loop to generate Fibonacci numbers until the error E in subsequent calculations of is less than or equal to the value of to1GR. Your function should assign values to three output variables as follows. 1. Assign the final calculated value of the Golden Ratio to the variable GoldenRatio with default double precision datatype. 2. Assign the largest Fibonacci number generated to the variable lastFib with 32-bit unsigned integer datatype. 3. Assign the number of terms required to meet the tolerance to the variable numTerms with 8-bit unsigned integer datatype. Note the value of to1GR is defined as an input to the function. Do not overwrite this value in your code. Be sure to assign values to each of the function output variables. Use a while loop in your solution.
Iterative Fibonacci (while loop, perils of integer arithmetic) The Fibonacci sequence defined by F=1,1,2, 3, 5, 8, 13, 21, 34, 55, 89, ... where the 4th term is given by F₁ = F₁-1+Fx-2 As k increases, the ratio of two adjacent terms in the sequence approaches the Golden Ratio, F₂ =drp. The goal of this problem is to generate Fibonacci numbers until the absolute value of the difference between subsequent computations of the Golden Ratio falls below a given tolerance. My Solutions E = |x-₁-1- Code has already been provided to define a function named fibGenerator that accepts a single input value into the variable to1GR. Add code that uses a while loop to generate Fibonacci numbers until the error E in subsequent calculations of is less than or equal to the value of to1GR. Your function should assign values to three output variables as follows. 1. Assign the final calculated value of the Golden Ratio to the variable GoldenRatio with default double precision datatype. 2. Assign the largest Fibonacci number generated to the variable lastFib with 32-bit unsigned integer datatype. 3. Assign the number of terms required to meet the tolerance to the variable numTerms with 8-bit unsigned integer datatype. Note the value of to1GR is defined as an input to the function. Do not overwrite this value in your code. Be sure to assign values to each of the function output variables. Use a while loop in your solution.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning