Fill 2-dimensional array with value

#include <iostream>

int main() {
    // Define the dimensions of the 2-dimensional array
    const int rows = 3;
    const int cols = 4;

    // Declare a 2-dimensional array with the specified dimensions
    int arr[rows][cols];

    // Define the value to be filled in the array
    int value = 42;

    // Use nested loops to iterate over each element in the array
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            // Assign the specified value to each element in the array
            arr[i][j] = value;
        }
    }

    // Display the filled 2-dimensional array
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            // Output the value of each element in the array
            std::cout << arr[i][j] << " ";
        }
        // Move to the next line after each row is printed
        std::cout << std::endl;
    }

    return 0;
}