// A 2D array is an array of 1D arrays. // Most ideas about 1D arrays generalize to 2D arrays. // // Notice that 2D arrays are initialized row-wise. #include #include using namespace std; int main() { const short P_ROWS = 4; const short P_COLS = 4; short i, j; float my_array[P_ROWS][P_COLS] = { { 1.0, 2.0, 3.0 }, { 5.0, 6.0, 7.0, 8.0 }, { 8.0, 7.0 }, { 4.0, 3.0, 2.0, 1.0 } }; cout.setf( ios::showpoint ); cout.setf( ios::fixed ); cout.precision(2); for ( i = 0; i < P_ROWS; i++ ) { for ( j = 0; j < P_COLS; j++ ) { cout << my_array[i][j] << " "; } cout << "\n"; } cout << "\n\n"; system( "PAUSE" ); return( EXIT_SUCCESS ); }