Deque Push Back Function - C++ Programming Tutorial
C++ Course / STL Queue & Stack / Deque Push Back Function

Deque Push Back Function

BLUF: Mastering Deque Push Back Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Deque Push Back Function

C++ is renowned for its efficiency. Learn how Deque Push Back Function enables low-level control and high-performance computing in the tutorial below.

C++ Deque push_back

The push_back method in a C++ Deque appends a new element to the back of the deque data structure, resulting in an increment in the container's size by one.

Syntax

Example

void  push_back(value_type val);

Parameter

val : The fresh value to be added at the conclusion of the deque container.

Return value

It does not return any value.

Example 1

Let's see a simple example

Example

#include <iostream>
#include<deque>
using namespace std;
int main()
{
    deque<int> d={10,20,30,40};
    deque<int>::iterator itr;
    d.push_back(50);
    for(itr=d.begin();itr!=d.end();++itr)
    cout<<*itr<<" ";
    return 0;
  }

Output:

Output

10 20 30 40 50

In this instance, the push_back method appends a new element, specifically 50, to the tail of the deque.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience