c++ loop through an array

#include <iostream>

int main() {
    // Declare and initialize an array
    int myArray[] = {1, 2, 3, 4, 5};

    // Determine the length of the array
    int arrayLength = sizeof(myArray) / sizeof(myArray[0]);

    // Loop through the array using a for loop
    for (int i = 0; i < arrayLength; ++i) {
        // Access and print each element of the array
        std::cout << "Element at index " << i << ": " << myArray[i] << std::endl;
    }

    return 0;
}