0% found this document useful (0 votes)
3 views2 pages

Array

An array is a derived data type in C that consists of a group of elements of the same type, stored in continuous memory and accessed via indices. It can be declared using the syntax 'Data type array_name[array_size];' and initialized with specific values. Multidimensional arrays, such as two-dimensional arrays, allow for the creation of arrays of arrays, enabling the storage of data in a grid format.

Uploaded by

srilasya652
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Array

An array is a derived data type in C that consists of a group of elements of the same type, stored in continuous memory and accessed via indices. It can be declared using the syntax 'Data type array_name[array_size];' and initialized with specific values. Multidimensional arrays, such as two-dimensional arrays, allow for the creation of arrays of arrays, enabling the storage of data in a grid format.

Uploaded by

srilasya652
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Array

Array is derived data type and it is a group of elements of same type.

Properties of Array

1. Each element of the array is same type and same size


2. Elements of the array are stored in Continuous memory
3. All the elements share the name but differentiated by means of index.

Declaration of C Array

Data type array_name [array_size];


Example

int mark[5];

Memory Allocation

Initialization of Array

int mark[5] = {19,10,8,17,9}

Printing the array elements

for(i=0;i<5;i++)
{
printf(“ %d \n”, mark[i])
}
Multidimensional Arrays
In C programming, it is possible to create an array of arrays. These arrays are known as
multidimensional arrays. For example,
int x[3[4];

Here, x is a two-dimensional (2d) array. The array can hold 12 elements. It can store
elements with 3 rows and each row has 4 columns.

Code to get input for two dimensional array

for(i =0;i<3;i++)
{
for(j=0;j<4;j++)
{
Scanf(“%d”, &x[i][j]);
}
}

You might also like