C++ Queue: Exercises, Practice, Solution
C++ Queue [27 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
From Wikipedia,
In computer science, a queue is a collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence. By convention, the end of the sequence at which elements are added is called the back, tail, or rear of the queue, and the end at which elements are removed is called the head or front of the queue, analogously to the words used when people line up to wait for goods or services.
1. Write a C++ program to implement a queue using an array with enqueue and dequeue operations. Find the top element of the stack and check if the stack is empty, full or not.
2. Write a C++ program to reverse the elements of a queue.
3. Write a C++ program to sort the elements of a queue.
4. Write a C++ program to find the sum of all elements of a queue.
5. Write a C++ program to find the average of all elements of a queue.
6. Write a C++ program to find the median of all elements of a queue.
7. Write a C++ program to find the mode of all elements of a queue.
8. Write a C++ program to find the mean, variance and standard deviation of all elements of a queue.
9. Write a C++ program to find the maximum element of a queue.
10. Write a C++ program to find the minimum element of a queue.
11. Write a C++ program to find the second highest element of a queue.
12. Write a C++ program to find the second lowest element of a queue.
13. Write a C++ program to remove a given element from a queue.
14. Write a C++ program to remove all the elements from a queue.
15. Write a C++ program to remove all even elements from a queue.
16. Write a C++ program to remove all odd elements from a queue.
17. Write a C++ program to remove all duplicate elements from a queue.
18. Write a C++ program to remove all elements greater than a number from a queue.
19. Write a C++ program to concatenate two queues.
20. Write a C++ program to copy one queue to another.
21. Write a C++ program to find the top and bottom elements of a queue.
22. Write a C++ program to get the Nth element from the bottom of a queue.
23. Write a C++ program to get the Nth element from the top of a queue.
24. Write a C++ program to find the position of an element in a queue.
25. Write a C++ program to check if two queues are equal.
26. Write a C++ program to find the intersection of two queues.
27. Write a C++ program to find the union of two queues.
CPP Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/cpp-exercises/queue/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics