Types of Arrays in C Programming Language
Notes:
Types of Arrays in C Programming Language :
Classification of arrays in C:
Arrays are mainly classified in to 2 types:
- One dimensional array
- Multi-dimensional arrays
Multi-dimensional arrays are again classified in to 2-dimensional, 3-dimensional and so on an n-dimensional array.
1-dimensional array:
While accessing each element in an array; if it requires only one index or subscript such an array is called 1-dimensional array.
Ex: arrayName[index]
Where: index can be a row index or column index
Because 1D array is used to store list of values arranged in a row or column i.e. set of values arranged in either x axis or y axis
2-dimensional array:
While accessing each element in an array; if it requires two indexes or subscripts such an array is called 2-dimensional array.
Ex: arrayName[index1] [index2]
Where: index1 must be a row index and index2 must be column index
Because 2D arrays are used to store table of values arranged in rows and columns i.e. set of values arranged in both x and y axis
3-dimensional array:
While accessing each element in an array; if it requires three indexes or subscripts such an array is called 3-dimensional array.
Ex: arrayName[index1] [index2][index3]
Where: index1 must be a x index, index2 must be y index & index3 must be z index
Because 3D arrays are used to store set of values arranged in x, y and z axis.
And so on …
n-dimensional array:
While accessing each element in an array; if it requires n indexes or subscripts such an array is called n-dimensional array.
Ex: arrayName[index1] [index2][index3]….[indexn]