#include#include int main() { std::array arr{}; // initialization with zeroes for (auto i: arr) { std::cout << i << " "; // prints "0 0 0 0 0" } return 0; }
#include#include int main() { std::array arr{1, 2, 3, 4, 5}; std::cout << arr[2] << "\n"; // prints "3" arr[3] = 0; for (auto i: arr) { std::cout << i << " "; // prints "1 2 3 0 5" } return 0; }
#includeThe `std::array` is part of the C++ Standard Library and is not a separate package library.#include #include int main() { std::array arr{5, 3, 2, 1, 4}; std::sort(arr.begin(), arr.end()); for (auto i: arr) { std::cout << i << " "; // prints "1 2 3 4 5" } return 0; }