#include#include using namespace std; int main() { array arr = { 10, 20, 30, 40, 50 }; cout << "Last Element: " << arr[arr.size() - 1] << endl; return 0; }
#includeIn this example, a vector of integers is defined with five elements. The last element of the vector is accessed using the back() function, which returns a reference to the last element of the container. The back function is available in the STL package library. With the above examples, the package library used is the Standard Template Library (STL), which provides many container classes and algorithms to work with them.#include using namespace std; int main() { vector vec = { 11, 22, 33, 44, 55 }; cout << "Last Element: " << vec.back() << endl; return 0; }