This function will calculate the n term in the Fibonacci Numbers and return in fib_no. By definition, the function returns 0 for n =1, and returns 1 for n = 2. For the subsequence number: nh = (n - 2)th + (n - 1)th You need to verify the input n > 0. Task 2 Sample Output Please enter the nth term Fibonacci number to compute: -1 Please enter a number greater than 0! Please enter the nth term Fibonacci number to compute: 12 The Fibonacci series is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 The 12th. term is: 89

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
A Fibonacci Number sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The
next number is calculated by adding up the two numbers before it. Write a program called
fib.cpp. The program will print out the n" Fibonacci Numbers using a function called:
void FibonacciNumber (int n, int& fib_no)
This function will calculate the n term in the Fibonacci Numbers and return in fib_no. By
definition, the function returns 0 for n=1, and returns 1 for n = 2. For the subsequence number:
nth = (n - 2)th + (n - 1)th
You need to verify the input n > 0.
Task 2 Sample Output
Please enter the nth term Fibonacci number to compute: -1
Please enter a number greater than 0!
Please enter the nth term Fibonacci number to compute: 12
The Fibonacci series is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89
The 12th. term is: 89
Transcribed Image Text:A Fibonacci Number sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is calculated by adding up the two numbers before it. Write a program called fib.cpp. The program will print out the n" Fibonacci Numbers using a function called: void FibonacciNumber (int n, int& fib_no) This function will calculate the n term in the Fibonacci Numbers and return in fib_no. By definition, the function returns 0 for n=1, and returns 1 for n = 2. For the subsequence number: nth = (n - 2)th + (n - 1)th You need to verify the input n > 0. Task 2 Sample Output Please enter the nth term Fibonacci number to compute: -1 Please enter a number greater than 0! Please enter the nth term Fibonacci number to compute: 12 The Fibonacci series is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 The 12th. term is: 89
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,