Arrays in C/C++

Two Dimensional Array IN C /C++

Two Dimensional Array is a best way of storing the same type of data in form of matrix or table. When we want to store the data in shape of Table (In rows, and Coulmns) then we us 2D, Two Dimensional Array.
Syntax of Declaration of Two Dimensional Array :
Array Data type Name of Array[num_of_rows] [num_of_column];

For Example
int student [5][3] ;

For example: (Storing The Marks for Three Subject about 5 student). In This Example we have 5 row which store the The Marks of 3 Subject Means 3 Columns.

void main(void)
int marks[5][3];  // Declaration of Array
int i , j; //Declaration of Other variable which
          //use in two loop , How ever we Declare all things in One Row.
for(i=0  ;i<=4  ;  i++)

    for(j=0;  j<=2  ;  j++)


scanf("%d \n",&marks[i][j];// this statement will get the marks[0][1] and up to son .



for(i=0  ;i<=4  ;  i++)


            for(j=0;  j<=2  ;  j++)

 // this statement will display the marks[0][1] and up to son .
printf("%d \t ",marks[i] [j]) ;




getch( ) ;


In above example if we enter the marks as


then the out put will be:

12    13    14

15    16    17

18    19    20

21    22    23

24    25    26