3. Structure is a collection of different items of data
types. A structure is a heterogeneous in that it can
be composed of data of different data types.
Example:- student record: student id , name, class…
Need of structure
In programming language array are used to store a
set of same data types. So when we use required a
collection of different data items we use structure.
In array it is not possible.
3
4. Declaration of structure & its
members
To declare a structure, we can use the keyword struct. The
collection of data items that need to be a part of the structure
are then declared within the braces.
syntax:
Struct structure_name
{
data type member1;
data type member2;
……;
……;
};
For example:
Struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
}; 4