#include#include int main() { std::array myArray = {1, 2, 3, 4, 5}; // Print array for (int i = 0; i < myArray.size(); i++) { std::cout << myArray[i] << " "; } // Change value of array element myArray[3] = 10; // Print changed array for (int i = 0; i < myArray.size(); i++) { std::cout << myArray[i] << " "; } return 0; }
#includeIn this example, two arrays called `myArray1` and `myArray2` are declared and initialized with five integer values each. A third array called `resultArray` is also declared, which will hold the sum of the two input arrays. A for loop is used to add each element in `myArray1` to the corresponding element in `myArray2`, and store the result in `resultArray`. Finally, the contents of `resultArray` are printed to the console. Overall, IntArray is a useful library for working with arrays of integers in C++. As it is a standard part of the C++ language, no additional package installation is required.#include int main() { std::array myArray1 = {1, 3, 5, 7, 9}; std::array myArray2 = {2, 4, 6, 8, 10}; // Add arrays together std::array resultArray = {}; for (int i = 0; i < myArray1.size(); i++) { resultArray[i] = myArray1[i] + myArray2[i]; } // Print result array for (int i = 0; i < resultArray.size(); i++) { std::cout << resultArray[i] << " "; } return 0; }