how to set arrays as function parameters in c++

#include <iostream>

// Function declaration with an array parameter
void printArray(int arr[], int size);

int main() {
    // Example array
    int myArray[] = {1, 2, 3, 4, 5};
    int size = sizeof(myArray) / sizeof(myArray[0]);

    // Call the function with the array as a parameter
    printArray(myArray, size);

    return 0;
}

// Function definition with an array parameter
void printArray(int arr[], int size) {
    // Loop through the array elements and print them
    for (int i = 0; i < size; ++i) {
        std::cout << arr[i] << " ";
    }

    // Add a newline character at the end
    std::cout << std::endl;
}