Answer to Question #287525 in C++ for Rerd

Question #287525

Develop a febonacci series of 20 numbers . Now push these elements into stack and then pop them . After pop , each element should get inserted into queue and after dequeuing each element should get inserted in linked list and then print that linked list .

1
Expert's answer
2022-01-14T04:36:25-0500
using namespace std;


#define N	10




void DisplayQ(queue<long int> Queue)
{
    while (!Queue.empty()) 
	{
        cout << Queue.front() << " ";
        Queue.pop();
    }
}
 
int main()
{
	long int Fib[N],a=0,b=1,c;
	int n;
	queue<long int> Queue;
	Fib[0] = a;
    Queue.push(Fib[0]);	
	Fib[1] = b;
    Queue.push(Fib[0]);	
	
	for(n=2;n<N;n++)
	{
		Fib[n] = a+b;
	    Queue.push(Fib[n]);	
		a=b;
		b = Fib[n];
	}
	DisplayQ(Queue);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment