2d array initialization and display

Hi There
I'm initializing my 2d array with
individual values, but I can't seem to output them.

// 2 dimensional arrays
#include <iostream>
using namespace std;

int main() {

int two_dimensional[3][5];
two_dimensional[0][0] = 1;
two_dimensional[1][0] = 2;
two_dimensional[2][0] = 3;
two_dimensional[0][1] = 4;
two_dimensional[1][1] = 5;
two_dimensional[2][1] = 6;
two_dimensional[0][2] = 7;
two_dimensional[1][2] = 8;
two_dimensional[2][2] = 9;
two_dimensional[0][3] = 10;
two_dimensional[1][3] = 11;
two_dimensional[2][3] = 12;
two_dimensional[0][4] = 13;
two_dimensional[1][4] = 14;
two_dimensional[2][4] = 15;

cout << two_dimensional[3][5];
cin.get();
return 0;
}
I would like to display all the values of my array
to display an array, you'll have to loop:
1
2
3
4
5
for(int i = 0; i < 3; i++){
    for(int j = 0; j < 5; j++){
        cout << two_dimensional[i][j];
    }cout << '\n';
}


by the way, there is a quicker way to initialise arrays:
1
2
3
int two_dimensional[3][5] = {
     {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}
};
Topic archived. No new replies allowed.