Hello friends how are you, today in this blog i will teach you what is Double Dimensional Array, syntax of Double Dimensional Array, how Double Dimensional Array works and many programs of Double Dimensional Array in a very simple way.
Let's start
1.Double dimensional array is called array of array.
2.It is organized as matrix that can be represented by the collection of rows and columns.
3.It is a collection of data of same data type.
4.It is used to store group of data simultaneously.
5.It can store data of same data type means an integer array can store only integer value ,character array can store only character value and so on.
6.We can not fetch data from array directly therefore we use index point.
7.The indexing of array always start with 0.
8.Index value is always an integer number.
9.Array may be of any data type like int, char, float etc.
👉Syntax
int a[3][3]={ {40,50,60},{10,20,30},{70,80,90} };
int a[5]; a[0][0]=40; a[0][1]=50; a[0][2]=60; a[1][0]=10; a[1][1]=20; a[1][2]=30; a[2][0]=70; a[2][1]=80; a[2][2]=90;
#include<stdio.h> int main() { int a[3][3]={{40,50,60},{10,20,30},{70,80,90}};//Initializing array printf("value at a[0][0]=%d\n",a[0][0]); printf("value at a[0][1]=%d\n",a[0][1]); printf("value at a[0][2]=%d\n",a[0][2]); printf("value at a[1][0]=%d\n",a[1][0]); printf("value at a[1][1]=%d\n",a[1][1]); printf("value at a[1][2]=%d\n",a[1][2]); printf("value at a[2][0]=%d\n",a[2][0]); printf("value at a[2][1]=%d\n",a[2][1]); printf("value at a[2][2]=%d\n",a[2][2]); } /* ### Output ### value at a[0][0]=40 value at a[0][1]=50 value at a[0][2]=60 value at a[1][0]=10 value at a[1][1]=20 value at a[1][2]=30 value at a[2][0]=70 value at a[2][1]=80 value at a[2][2]=90 */
#include<stdio.h> int main() { int a[3][3]={{40,50,60},{10,20,30},{70,80,90}};//Initializing array for(int i=0;i<=2;i++) { for(int j=0;j<=2;j++) { printf("%d ",a[i][j]); } printf("\n"); } } /* ### Output ### 40 50 60 10 20 30 70 80 90 */
#include<stdio.h> int main() { int a[3][3];//Declaring array int i,j; //Nested loop for user input for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { printf("Enter element at a[%d][%d]=",i,j); scanf("%d",&a[i][j]); } } //Nested loop for printing output for(i=0;i<=2;i++) { for(j=0;j<=2;j++) { printf("%d ",a[i][j]); } printf("\n"); } } /* ### Output ### Enter value at a[0][0]=4 Enter value at a[0][1]=5 Enter value at a[0][2]=6 Enter value at a[1][0]=1 Enter value at a[1][1]=2 Enter value at a[1][2]=3 Enter value at a[2][0]=7 Enter value at a[2][1]=8 Enter value at a[2][2]=9 4 5 6 1 2 3 7 8 9 */
0 Comments