length of array in cpp

#include <iostream>

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

    // Calculate the length of the array
    int length = sizeof(arr) / sizeof(arr[0]);

    // Output the length of the array
    std::cout << "Length of the array: " << length << std::endl;

    return 0;
}