fill two dimensional array c++
#include <iostream>
int main() {
const int rows = 3;
const int cols = 4;
int twoDArray[rows][cols];
// Filling the two-dimensional array
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
// Assuming you want to fill with consecutive integers
twoDArray[i][j] = i * cols + j + 1;
}
}
// Displaying the filled two-dimensional array
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
std::cout << twoDArray[i][j] << " ";
}
std::cout << std::endl;
}
return 0;
}