Two dimensional Arrays In Data Structure

A two-dimensional array in C is an array of arrays, where each element of the array is itself an array. This can be used to represent tables or matrices. Here's an example implementation of a two-dimensional array in C:

```
#include <stdio.h>

int main() {
    int arr[3][4] = {
        {1, 2, 3, 4},
        {5, 6, 7, 8},
        {9, 10, 11, 12}
    };
    // Print elements of array
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 4; j++) {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}
```

In this implementation, `arr` is a two-dimensional array with 3 rows and 4 columns. It is initialized with the values 1 through 12. The `main()` function iterates through the rows and columns of the array and prints each element. The output of the program will be:


```
1 2 3 4
5 6 7 8
9 10 11 12
```

Note that the elements of the array are accessed using two indices, one for the row and one for the column. The first index specifies the row number, and the second index specifies the column number.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext