#includeint main() { std::array arr = {2, 4, 6, 8, 10}; auto it = arr.begin(); // iterator pointing to the first element std::cout << *it << std::endl; // prints 2 return 0; }
#includeIn this example, we create an `std::array` of doubles with 3 elements and initialize it with some values. Then, we use a for loop to iterate through the array. We create an iterator `it` pointing to the first element using `a.begin()`. We print the value of each element using the dereference operator `*`. Package/Library: The `std::array` class is part of the C++ Standard Library (STL), which is included in the `std` namespace.int main() { std::array a = {2.5, 4.1, 6.0}; for (auto it = a.begin(); it != a.end(); ++it) { std::cout << *it << ' '; // prints 2.5 4.1 6 } return 0; }