#include #include #include #include using namespace std; int main() { // Declare and initialize a array of 5 integers array numbers = {1, 2, 3, 4, 5}; // Access elements using the bracket operator cout << "Element at index 2: " << numbers[2] << endl; // Output: 3 // Access elements with bounds checking using at() try { cout << "Element at index 4: " << numbers.at(14) << endl; // Output: 5 // cout << numbers.at(5) << endl; // This would throw an exception } catch (const out_of_range& e1) { cerr << "Error: " << e1.what() << endl; } // Iterate using a range-based for loop cout << "All elements: "; for (int num : numbers) { cout << num << " "; } cout << endl; array::iterator iter1 = numbers.begin() ; for ( ; iter1 != numbers.end() ; iter1++ ) { cout << *iter1 << " "; } cout << endl; // Get the size of the array cout << "Array size: " << numbers.size() << endl; // Output: 5 return 0; }