Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help in c++ with explanation would be great! Assignment 2 CS222. Program #2. 15 points + 2 extra) Re-write a program to compute Fibonacci number

help in c++ with explanation would be great! image text in transcribed
Assignment 2 CS222. Program #2. 15 points + 2 extra) Re-write a program to compute Fibonacci number using a recursion Fibonacci numbers have the property that each consecutive number is a sum of two preceding: 0,1,1,2,3,5,8, 13. 21... Your program should ask user for the integer, and output the result, which shows Fibonacci number at that position. For example if user enters 5. program should output 3' (fifth position in the series) Your program should use recursive function to compute and return back to the main the Fibonacci number Extra points: Add another function to calculate Fibonacci number using the loop (not the recursion). These two methods should give you the same result. Main asks user for the input, calls the function(s) to calculate the Fibonacci number, and outputs the result back to the user. Comment your program: Programmer: Your name Purpose: State the purpose of the program Class: CS222 Assignment number 2. Describe all variables Describe important section of code. Grading Comments Indentation Meaningful variables names Program runs Correct input and output Total Extra: Function to calculate Fibonacci numbers with the loop 2 points 2 points 2 points 4 points S points 15 points 2 points Deductions: Run-away recursion: -5 points How to submit: Submit the source file (.cpp) and the run file (.txt) on or before the due time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions