সি ভাষা তিন বা ততোধিক ডাইমেনশনের অ্যারে অনুমতি দেয়, এটিকে মাল্টিডাইমেনশনাল অ্যারে বলা হয়। সঠিক লিমিট কম্পাইলারের ওপর নির্ভর করে।
সিনট্যাক্স
datatype arrayname[size1][size2]...[sizen];
উদাহরণ: int a[3][3][3]; (৩-ডাইমেনশনাল) -> উপাদান সংখ্যা = 3*3*3 = 27।
উদাহরণ প্রোগ্রাম: 5x5 অ্যারের রো এবং কলাম যোগফল
void main() {
int A[5][5], i, j, row=0, column=0;
printf("Enter elements into the array : \n");
for(i=0; i<5; i++) {
for(j=0; j<5; j++) {
printf("A[%d][%d] : ", i, j);
scanf("%d", &A[i][j]);
}
}
// রো যোগফল
for(i=0; i<5; i++) {
for(j=0; j<5; j++)
row = row + A[i][j];
printf("The sum of elements in row number %d is : %d\n", i, row);
row = 0;
}
// কলাম যোগফল
for(j=0; j<5; j++) {
for(i=0; i<5; i++)
column = column + A[i][j];
printf("The sum of elements in column number %d is : %d\n", j, column);
column = 0;
}
}
আউটপুট (নমুনা)
Enter elements into the array: A[0][0] : 1 ... A[4][4] : 8 The sum of elements in row number 0 is: 15 The sum of elements in row number 1 is: 22 The sum of elements in row number 2 is: 24 The sum of elements in row number 3 is: 17 The sum of elements in row number 4 is: 30 The sum of elements in column number 0 is: 12 The sum of elements in column number 1 is: 25 The sum of elements in column number 2 is: 22 The sum of elements in column number 3 is: 26 The sum of elements in column number 4 is: 23