Answer the following questions for the given code snippet. 1- int main (){ 2 Queue q; 3 int i; 4 5 cin>>i; 6 7 while (i

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Answer the following questions for the given code snippet. 1- int main (){ 2 Queue q; 3 int i; 4 5 cin>>i; 6 7 while (i

Post by answerhappygod »

Answer The Following Questions For The Given Code Snippet 1 Int Main 2 Queue Q 3 Int I 4 5 Cin I 6 7 While I 1
Answer The Following Questions For The Given Code Snippet 1 Int Main 2 Queue Q 3 Int I 4 5 Cin I 6 7 While I 1 (205.66 KiB) Viewed 61 times
Answer the following questions for the given code snippet. 1- int main (){ 2 Queue q; 3 int i; 4 5 cin>>i; 6 7 while (i != -1){ if (i %2 8 0) 9 q. enqueue(i); 10 cin>>i; 11 } 12- while (!q.isEmpty()) { 13 q.dequeue(); 14 cout <<i << endl; 15 } 16} 1- Given the following input, what does the above C++ code display? 1-2-3-4-5-6-7-8-9-10--1 2- What if a stack was used instead of queue (push instead of enqueue and pop instead of dequeue)? What does the above C++ code will display then given The same set of input?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply