1//C++ STL program to demonstrate example of
2//vector::empty() function
3
4#include <iostream>
5#include <vector>
6using namespace std;
7
8int main()
9{
10 vector<int> v1;
11
12 //printing the size of the vector
13 cout << "Total number of elements: " << v1.size() << endl;
14 //checking whether vector is empty or not
15 if (v1.empty())
16 cout << "vector is empty." << endl;
17 else
18 cout << "vector is not empty." << endl;
19
20 //pushing elements
21 v1.push_back(10);
22 v1.push_back(20);
23 v1.push_back(30);
24 v1.push_back(40);
25 v1.push_back(50);
26
27 //printing the size of the vector
28 cout << "Total number of elements: " << v1.size() << endl;
29 //checking whether vector is empty or not
30 if (v1.empty())
31 cout << "vector is empty." << endl;
32 else
33 cout << "vector is not empty." << endl;
34
35 return 0;
36}
37