In C programming, arrays are used to store multiple values in a single variable. An array is a collection of elements, all of the same data type, stored in contiguous memory locations.
A 1D array is a list of elements arranged in a single row.
data_type array_name[size];
int marks[5] = {90, 85, 78, 92, 88};
marks[0] returns 90marks[4] returns 88A 2D array is a table or matrix of elements. It uses two indices: row and column.
data_type array_name[rows][columns];
int matrix[2][3] = {
{1, 2, 3},
{4, 5, 6}
};
matrix[0][1] returns 2matrix[1][2] returns 6A Multi-Dimensional Array is an extension of 2D arrays and can go up to any number of dimensions (like 3D).
data_type array_name[size1][size2][size3]...;
int cube[2][2][2] = {
{
{1, 2},
{3, 4}
},
{
{5, 6},
{7, 8}
}
};
cube[0][0][1] → 2cube[1][1][1] → 8int cube[2][2][2]This declaration creates a 3D array with:
cube[0])cube[1])Tip: Think of it as a cube of data like cube[block][row][column]
Note: The more dimensions, the more memory and complexity involved. Start with 1D or 2D for most beginner use cases.