Embed presentation
Downloaded 11 times

![What is array ?
An array is a collection of variables of the same data type that
are referenced by a common name .
Eg:
int arr[3];
0 (2bytes) 1(2bytes) 2(2bytes)
arr[0] arr[1] arr[2]](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-2-320.jpg)
![What is structure ?
A structure is a grouping of several variables of different
data types. Struct keyword is used.
Eg:
struct book
{ int page; (2bytes) (15bytes) (4bytes)
char author[15]; page author price
float price;
};](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-3-320.jpg)

![Arrays of structures
Eg:
struct fraction
{
int numerator; // 2 bytes
int denominator; //2 bytes
};
Struct fraction f1[4]; // this is an array of structure](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-5-320.jpg)
![Memory allocation of arrays of structures
Total size of f1 = 4*2*2=16 bytes
0 (4) 1 (4) 2 (4) 3(4)
N D N D N D N D
f1[0] f1[1] f1[2] f1[3]](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-6-320.jpg)
![Accessing the elements of array of structure
Struct fraction f1[4];
For(i=0;i<4;i++)
{
Printf(“%d”,f1[i].numerator);
Printf(“%d”,f1[i].denominator);
}](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-7-320.jpg)


An array is a collection of variables of the same type referenced by a common name. A structure groups variables of different types. An array of structures combines these concepts by creating an array where each element is a structure. For example, an array of fraction structures could be defined to hold multiple fractions. Each structure element in the array contains a numerator and denominator integer. The entire array of structures occupies a contiguous block of memory with each structure taking up the same amount of space. Individual structure elements can then be accessed using the array index and dot notation.

![What is array ?
An array is a collection of variables of the same data type that
are referenced by a common name .
Eg:
int arr[3];
0 (2bytes) 1(2bytes) 2(2bytes)
arr[0] arr[1] arr[2]](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-2-320.jpg)
![What is structure ?
A structure is a grouping of several variables of different
data types. Struct keyword is used.
Eg:
struct book
{ int page; (2bytes) (15bytes) (4bytes)
char author[15]; page author price
float price;
};](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-3-320.jpg)

![Arrays of structures
Eg:
struct fraction
{
int numerator; // 2 bytes
int denominator; //2 bytes
};
Struct fraction f1[4]; // this is an array of structure](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-5-320.jpg)
![Memory allocation of arrays of structures
Total size of f1 = 4*2*2=16 bytes
0 (4) 1 (4) 2 (4) 3(4)
N D N D N D N D
f1[0] f1[1] f1[2] f1[3]](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-6-320.jpg)
![Accessing the elements of array of structure
Struct fraction f1[4];
For(i=0;i<4;i++)
{
Printf(“%d”,f1[i].numerator);
Printf(“%d”,f1[i].denominator);
}](https://image.slidesharecdn.com/c-140825090928-phpapp02/85/arrays-of-structures-7-320.jpg)
