#include#include int main() { std::vector v {1, 2, 3, 4, 5}; std::cout << v[2]; // accessing the third element (3) return 0; }
#includeThis code creates a vector `v` of integer data type and initializes it with the values {1, 2, 3, 4, 5}. It then adds a new element 6 at the end of the vector using `push_back` method and removes the last element of the vector using `pop_back` method. Finally, it prints all the elements of the vector on the console. The package library associated with `typenamestd vector` is the C++ Standard Library.#include int main() { std::vector v {1, 2, 3, 4, 5}; v.push_back(6); // add 6 at the end v.pop_back(); // removes last element for(int i : v) std::cout << i << " "; // prints all elements return 0; }