Skip to main content Accessibility help
Internet Explorer 11 is being discontinued by Microsoft in August 2021. If you have difficulties viewing the site on Internet Explorer 11 we recommend using a different browser such as Microsoft Edge, Google Chrome, Apple Safari or Mozilla Firefox.

Chapter 15: Structure

Chapter 15: Structure

pp. 416-460

Authors

, Techno India Hooghly, West Bengal, , Techno India College of Technology, West Bengal
  • Add bookmark
  • Cite
  • Share

Extract

So far the data types that are used in our programs are primitive or basic data types. However, C language provides the facilities to construct our own data types. These are known as user-defined data types. User-defined data type, also known as derived data type is constructed using primitive data types and/or other user-defined data type.

Already we have seen that array is a collection of homogeneous elements. But in real life, we need to store heterogeneous elements that are highly related to each other and thus demands to store as a single logical unit. For example, to store the information about a student, we need to store roll number which is integer, name which is a string, fees may be of type float and so on. Structure helps us to handle this situation.

STRUCTURE

A structure is a collection of heterogeneous elements. Basically it provides a template to define a set of similar or dissimilar elements under a single name. It helps programmers to group heterogeneous but highly related data elements into a single logical unit. It is a user-defined data type that constructed using primitive data types. To declare a structure, the keyword struct is used. The general form to declare a structure the statement is given below: where struct is a keyword to define a structure. The structure name is called tag and it specifies the name of the structure being defined. Members of the structure may be of same or different data types. They may be of primitive data type or any derived data type.

About the book

Access options

Review the options below to login to check your access.

Purchase options

Paperback
US$105.00

Have an access code?

To redeem an access code, please log in with your personal login.

If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.

Also available to purchase from these educational ebook suppliers