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.
#include #include #include 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]) ; } printf("\n"); } getch( ) ; } In above example if we enter the marks as 12,13,14,15,16,17,18,19,20,22,23,24,25,26 then the out put will be: 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Declaring and Initializing Local Variable in C
Declaring and Initializing Global Variable in C Language
Printf Function In C Language
Sacnf Function In C Language
for Loop in C Language
While Loop in C Language
Do While Loop in C Language
Switch Case Statement IN C
IF -Else Statement IN C
Break Statement IN C /C++
User Define Function IN C /C++
Cout/Cin Function IN C /C++
Array IN C /C++
Two Dimensional Array IN C /C++
String In IN C /C++
Pointer In IN C /C++
Const and volatile keyword IN C /C++
Class and Object in C++
Function Over Loading in C++
Character Array In C++
Constructor in C++
Operator overloading in C++
Function Templates in C++
ATM Sample Project In Simple C Language
Find Area of Shape Using Function In C++