c++ how to display a 2d array code example
Example 1: print 2d array c++
for( auto &row : arr) {
for(auto col : row)
cout << col << " ";
cout<<endl;
}
Example 2: how to print a 2d array in c++
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cout << arr[i][j] << " ";
}
// Newline for new row
cout << endl;
}