print array c++

include

using namespace std;

int main() { int arr[] = {1, 2, 3, 4, 5}; // Declare and initialize an integer array named 'arr' with values 1, 2, 3, 4, and 5. int size = sizeof(arr)/sizeof(arr[0]); // Calculate the size of the array by dividing the size of the whole array by the size of a single element.

for(int i = 0; i < size; i++) { // Loop through each element of the array using a for loop.
    cout << arr[i] << " "; // Print the value of each element followed by a space.
}

return 0;

}