1#include <bits/stdc++.h>
2using namespace std;
3int main(){
4 vector<int> v1{10, 20, 30, 40, 50};
5
6 //removing elemenets
7 v1.pop_back(); //removes 50
8 v1.pop_back(); //removes 40
9
10}
1// vector::pop_back
2#include <iostream>
3#include <vector>
4
5int main ()
6{
7 std::vector<int> myvector;
8 int sum (0);
9 myvector.push_back (100);
10 myvector.push_back (200);
11 myvector.push_back (300);
12
13 while (!myvector.empty())
14 {
15 std::cout<<myvector.back()<<" ";
16 myvector.pop_back();
17 }
18
19 std::cout << "The elements of myvector add up to " << sum << '\n';
20
21 return 0;
22}