Deque Push Back Function

C++ Deque push_back

C++ Deque push_back function adds a new element at the end of the deque container and the size of the container is increased by one.

Syntax

Example

void  push_back(value_type val);

Parameter

val : New value to be inserted at the end 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 example, push_back function adds new element i.e 50 at the end of the deque.

Input Required

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