
In c++
The Fibonacci numbers are a series of numbers that exhibit the following pattern:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …
The series starts with 0 and 1, and each subsequent number in the series is the sum of the previous two numbers. The Fibonacci sequence, Fn, is defined by the following recurrence relation:
Fn = Fn-1 + Fn-2
Where the initial values are F0 = 0 and F1 = 1. Write a program that prompts the user to enter in a positive integer N and generates the Nth Fibonacci number. Your main function should handle user input and pass that data to a function called Fib that takes integer N as input and returns the Nth Fibonacci number. Include the functions preconditions and postconditions as comments in your source code. Include some basic input validation to make sure the function’s preconditions are met before the function is called. Show your source code and a sample of your program output.

The algorithm of the code:-
Step 1: Start
Step 2: Declare an integer a = 0, b = 1, c, and i.
Step 3: Check if N is less than or equal to 0, if yes return 0.
Step 4: Set the loop, for i = 2 to N do the following steps.
Step 5: Calculate the value of c = a + b.
Step 6: Set a = b.
Step 7: Set b = c.
Step 8: End loop.
Step 9: Return the value of b.
Step 10: Stop
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

- please solve number C I solved numbers a and b so I do not need number a and b Problem (taken from page 308 of the textbook)A parking lot has 31 visitor spaces, numbered from 0 to 30. Visitors are assigned parking spaces usingthe hashing function h(k) = k mod 31, where k is the number formed from the first three digits on avisitor’s license plate.a) Which spaces are assigned by the hashing function to cars that have these first three digits ontheir license plates: 317, 918, 007, 100, 111, 310?b) Describe a procedure visitors should follow to find a free parking space when the space they areassigned is occupied.c) A large parking-systems company would like to automate your assignment procedure forselfparking cars. You have been hired to implement a ”simple” proof-of-concept program in C++, fornow customers will enter their 3 digit plate numbers and your software will assign a parkingspace. Your implementation should a find a free parking space if the original assigned space isoccupied.…arrow_forwardLINKED LIST IMPLEMENTATION Subject: Data Structure and Algorithm in C++Create a Student Record Management system that can perform the following operations:1) Insert student records2) Delete student record3) Show student record4) Search student record The student record should contain the following items1) Name of Student2) Student Matriculation ID number3) Course in which the student is enrolled4) Total marks of the student Approach: With the basic knowledge of operations of Linked Lists like insertion, deletion of elements in linked list, the student record management can be created. Below are the functionalities explained that are to be implemented.●Check Record: It is a utility function of creating a record it checks before insertion that the Record Already exist or not. It uses the concept of checking for a Node with given Data in a linked list.-Create Record: It is as simple as creating a new node in the Empty Linked list or inserting a new node in a non-Empty linked list.-Search…arrow_forwardWrite in C Language Description Please finish the following function char *replace(charsource, char constpattern, char constreplacement) A sequence of calls to this function replace the pattern with replacement. On a first call, the function expects a C string as argument for source, and this function scan for source to find the first pattern appear in source than replace it with replacement. In subsequent calls, the function expects a null pointer and uses the position right after the end of the last replacement as the new starting location for scanning. This function return source. Please see following example. char source[100] = "1223456789", pattern[10] = "2", replacement[10] = "123"; printf("%s", replace(source, pattern, replacement)); //Here should print out 112323456789 printf("%s", replace(source, pattern, replacement)); //Here should print out 11123323456789 printf("%s", replace(NULL, pattern, replacement)); //Here should print out 1112331233456789 function char…arrow_forward
- 1. Find the first 6 terms of the recurrence relation given bya1 = -1, an = 2n – an-1 2. a. Create a Python recursive function for the relation in #1. b. Create a Python program that uses a for loop to repeatedly invoke the recursive. the function you created and to print each term up to and including a6.Include a screenshot of the Python file that contains yourfunction code and your program code. Include a screenshot of your IDLE output. 3. Trace the following function. Do not just provide the output. Include the state of memory for each function call (use your text as a guide). Show the value of n and the value of f(n) for each value of n. Show return values. Show what is printed for each value of n, as well as the result of any other print statements: def f(n): print (n) if n ==0: return 5 else: return (n**2) + f(n-1)print (“Invoking the function”)print (f(3))print (“done”)arrow_forwardF(A,B,C, D,E) =E ml0,1;3,6,8,9,14,ky1319,25,2931) DE 61 10 60 00 61 10arrow_forwardbinary search c++ recursivearrow_forward
- Solve in C++ using the given code and avoid using vectorsarrow_forwardprogram in C++ with the name, towers.cpp which helps to solve the Towers of Hanoi puzzle using this recursive approach. The main() routine should make a single call to the recursive member function do Towers(). This function then calls itself recursively until the puzzle is solved. Note: solve as soon as possiblearrow_forward4. A={3,4}, B={4,5}. An B= AUB= A-B= A OB= AXB=arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





