Skip to main content Accessibility help
×
Hostname: page-component-6bb9c88b65-zjgpb Total loading time: 0 Render date: 2025-07-27T09:32:08.900Z Has data issue: false hasContentIssue false

15 - Structure

Published online by Cambridge University Press:  17 July 2025

Subrata Saha
Affiliation:
Techno India Hooghly, West Bengal
Subhodip Mukherjee
Affiliation:
Techno India College of Technology, West Bengal
Get access

Summary

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.

Information

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2016

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Accessibility standard: Unknown

Accessibility compliance for the PDF of this book is currently unknown and may be updated in the future.

Save book to Kindle

To save this book to your Kindle, first ensure no-reply@cambridge-org.demo.remotlog.com is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×