Multi Dimensional Arrays


#include "stdafx.h"
#include <iostream>

using namespace std;

// Multi dimensional arrays

int main ()
{  
  int myArray[3][5] =        // An array with 3 rows and 5 columns
  {
    { 1, 2, 3, 4, 5, }, // row 0
    { 6, 7, 8, 9, 10, }, // row 1
    { 11, 12, 13, 14, 15 } // row 2
  };

  int newArray[][5] =         //Two-dimensional arrays with initializer lists can omit (only) the first size specification
  {
    { 1, 2, 3, 4, 5, },
    { 6, 7, 8, 9, 10, },
    { 11, 12, 13, 14, 15 }
  };

  cout<< "Values of myArray :" << endl;

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 5; j++)
    {
      cout << myArray[i][j];
      cout<< " ";
    }
    cout<< endl;
  }

  return 0;
}

Output:
Values of myArray :
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15