multidemsional array in C++ with Simple Example


In C++ you can define multidimensional arrays with any number of dimensions. The ANSI standard stipulates a minimum of 256 dimensions but the total number of dimensions is in fact limited by the amount of memory available. The most common multidimensional array type is the two-dimensional array, the socalled matrix.

multidemsional array in C++ Program

#include <iostream> #include <iomanip> using namespace std; char representative[2][20] = {"Armstrong, Wendy", "Beauty, Eve"}; // Each representative has five different // articles available, having sold the following: int articleCount[2][5] = { { 20, 51, 30, 17, 44}, {150, 120, 90, 110, 88} }; int main() { for( int i=0; i < 2; i++ ) { cout <<"\nRepresentative: " << representative[i]; cout << "\nNumber of items sold: "; for( int j = 0; j < 5; j++ ) cout << setw(6) << articleCount[i][j]; cout << endl; } return 0; }