How to Dequeue an Element from a Queue in C++? Last Updated : 29 Feb, 2024 Comments Improve Suggest changes Like Article Like Report In C++, queues are a type of container adaptors that operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front. In this article, we will learn how to dequeue an element from a queue in C++ STL. Example: Input: Create a queue and enqueue the values {1, 2, 3, 4, 5}.Output: Queue after dequeue: {2, 3, 4, 5}, after dequeue the first element.Dequeuing an Element from a Queue in C++To dequeue an element from a queue in C++, we can use the std::queue::pop() function. This function deletes or dequeues the first element of the queue. C++ Program to Dequeue an Element from a Queue C++ // C++ Program to illustrate how to dequeue an element from // a queue #include <iostream> #include <queue> using namespace std; // Driver Code int main() { // Creating a queue of integers queue<int> q; // Enqueueing elements into the queue for (int i = 1; i <= 5; ++i) { q.push(i); } // Dequeueing an element from the queue q.pop(); // Displaying the queue elements while (!q.empty()) { cout << q.front() << " "; q.pop(); } cout << endl; return 0; } Output2 3 4 5 Time Complexity: O(1) Space Complexity: O(1) Comment More infoAdvertise with us Next Article How to Dequeue an Element from a Queue in C++? R rohitpant4532 Follow Improve Article Tags : C++ Programs C++ STL cpp-deque CPP Examples +1 More Practice Tags : CPPSTL Similar Reads How to Remove an Element from a Deque in C++? In C++ STL, a container called deque (known as a double-ended queue) allows us to insert and delete elements at both its beginning and its end. In this article, we will learn how to remove a specific element from a deque in C++ STL. Example: Input: myDeque= {4, 2, 3, 5, 2} Target = 4 Output: Deque A 2 min read How to Delete an Element from a Priority Queue in C++ ? In C++, a priority queue is a queue in which elements are arranged based on their priority values as each element has a priority value associated with it. In this article, we will learn how to delete an element from a priority queue in C++. For Example, Input: myPriorityQueue = {8, 6, 7, 5, 4, 2, 3} 2 min read How to Remove an Element from the End of a Deque in C++? In C++, deque is also called a double-ended queue where we can insert new elements at both the front and back of the container. In this article, we will learn to remove an element from the end of a deque in C++. Example: Input: myDeque = {1, 2, 3, 4, 5} Output: Deque after removal: 1 2 3 4 Removing 2 min read How to Clear All Elements from a Deque in C++? In C++, deque also known as double-ended queue is a container provided by the Standard Template Library (STL) that allows efficient insertion and deletion at both ends. In this article, we will learn how to clear all elements from a deque in C++. Example: Input: myDeque = {10, 20, 30, 40}; Output: A 2 min read How to Replace an Element in a Deque in C++? In C++, deque (short for double-ended queue) allows fast insertions and deletions at both its beginning and its end. In this article, we will learn how to replace a specific element in a deque in C++. Example: Input: myDeque: {1, 2, 3, 4, 5, 3, 7} Output: // Replaced element 3 with 10 Updated Deque: 2 min read Like