#include#include int main() { std::vector v{1, 2, 3, 4, 5}; for (auto i : v) { std::cout << i << " "; } return 0; } // Output: 1 2 3 4 5
#includeDescription: In this example, an element 6 is added to the vector using the push_back() function. The elements are again accessed using a range-based for loop and then printed. These examples use the package library, which provides a range of functions, including element access, modification, and addition, to manipulate vectors. The package library has a comprehensive set of functions that allows the programmer to work with vectors in a more convenient and efficient way.#include int main() { std::vector v{1, 2, 3, 4, 5}; v.push_back(6); for (auto i : v) { std::cout << i << " "; } return 0; } // Output: 1 2 3 4 5 6