#include<vector>
#include<algorithm>
// all the std and main syntax ofcourse.
vector<int> pack = {1,2,3} ;
// To add at the END
pack.push_back(6); // {1,2,3,6}
// OR
// To add at BEGGINING
pack.insert(pack.begin(),6) // {6,1,2,3,}
std::vector<int> vecOfNums{ 1, 4, 5, 11, -3, -10, 15 };
// Inserting a single element:
auto itPos = vecOfNums.begin() + 2; // Iterator to wanted postion
vecOfNums.insert(itPos, 77); // Insert new Element => 1, 4, 77, 5, ..
// Inserting part or full other vector
std::vector<int> otherVec{ 33, 33, 55 };
vecOfNums.insert(vecOfNums.begin() + 1, otherVec.begin(), otherVec.begin() + 2); // 1, 33, 33, 4, ..
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> num {1, 2, 3, 4, 5};
cout << "Initial Vector: ";
for (const int& i : num) {
cout << i << " ";
}
num.push_back(6);
num.push_back(7);
cout << "
Updated Vector: ";
for (const int& i : num) {
cout << i << " ";
}
return 0;
}