Insert into vector C++

C++
// Program below illustrates the 
// vector::insert() function 
  
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    // initialising the vector 
    vector<int> vec = { 10, 20, 30, 40 }; 
  
    // inserts 3 at front 
    auto it = vec.insert(vec.begin(), 3); 
    // inserts 2 at front 
    vec.insert(it, 2); 
  
    int i = 2; 
    // inserts 7 at i-th index 
    it = vec.insert(vec.begin() + i, 7); 
  
    cout << "The vector elements are: "; 
    for (auto it = vec.begin(); it != vec.end(); ++it) 
        cout << *it << " "; 
  
    return 0; 
} 
vector_name.push_back(element_to_be_added);#include<bits/stdc++.h>
using namespace std;

int main()
{
    vector<int> vec = {20, 30, 50, 60};
    vec.insert(vec.begin()+2, 40);
    for(auto x:vec)
    {
        cout << x << " ";
    }

    return 0;
}// CPP program to create an empty vector 
// and push values one by one. 
#include <vector>

using namespace std;
int main() 
{ 
    // Create an empty vector 
    vector<int> vect;  
    //add/push an integer to the end of the vector
    vect.push_back(10); 
	//to traverse and print the vector from start to finish
    for (int x : vect) 
        cout << x << " ";

    return 0; 
}std::vector<int> v;
v.push_back(10);// inserting into a vector
#include <iostream>
#include <vector>

int main ()
{
  std::vector<int> myvector (3,100);
  std::vector<int>::iterator it;

  it = myvector.begin();
  it = myvector.insert ( it , 200 );

  myvector.insert (it,2,300);

  // "it" no longer valid, get a new one:
  it = myvector.begin();

  std::vector<int> anothervector (2,400);
  myvector.insert (it+2,anothervector.begin(),anothervector.end());

  int myarray [] = { 501,502,503 };
  myvector.insert (myvector.begin(), myarray, myarray+3);

  std::cout << "myvector contains:";
  for (it=myvector.begin(); it<myvector.end(); it++)
    std::cout << ' ' << *it;
  std::cout << '\n';

  return 0;
}
Source

Also in C++: