2 Dimensional Arrays in C++
learning arrays in C++

See All Responses Below...
Author
Message Rating
Posted on: 11/06/2013
See the YouTube Video tutorial form the Link below to know more about 2 Dimensional Arrays in C++
http://www.youtube.com/watch?v=KOJG__fc1Ok
Posted on: 25/02/2016

Two Dimensional Array

It is a collection of data elements of same data type arranged in rows and columns (that is, in two dimensions).

Declaration of Two-Dimensional Array

Type arrayName[numberOfRows][numberOfColumn];

For example,
int Sales[3][5];

Referring to Array Elements

To access the elements of a two-dimensional array, we need a pair of indices: one for
the row position and one for the column position. The format is as simple as:
name[rowIndex][columnIndex]

Examples:
cout<<A[1][2];      //print an array element
A[1][2]=13;         // assign value to an array element
cin>>A[1][2];       //input element

Using Loop to input an Two-Dimensional Array from user

int mat[3][5], row, col ;
for (row = 0; row < 3; row++)
  for (col = 0; col < 5; col++)
    cin >> mat[row][col];


Share this page across other social networking sites



Please Login to Post Your Comments
Name (Max. 100 characters)
Please post your comments here
Select Language
Comments
Attach File(Max. Size: 2 MB)
A few simple rules when posting your Comments,
  1. Please post only answers relevant to the topic of discussion.
  2. Please dont misuse this site or do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will delete your inappropriate messages and will block or delete your account on this site.