Need a C++ program for Fibonacci function using Stack Fibonacci function Fib(n)
ID: 3755247 • Letter: N
Question
Need a C++ program for Fibonacci function using Stack
Fibonacci function Fib(n) is given below.
Fib(n)= Fib(n-1) + Fib(n-2) for n > 1
Fib(n)= 1 for n=1
Fib(n)= 0 for n=0
Using following initialization
unsigned int *Fib = new unsigned int[30];
and function prototypes
void push(int n, unsigned int * Fib)
unsigned int pop(unsigned int * Fib )
insert first 30 Fibonacci numbers into dynamic array Fib and then pop them to print out first 30 numbers in descending order.
The output of your program should be
514229, 317811, 196418, ......, 1, 1, 0
Explanation / Answer
int factorial(int n); void main() { int number,nfact; while(1) { cout number; if (numberRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.