What is a structure?

A structure is defined as a collection of data of same/different data types. All data items thus grouped are logically related and can be accessed using variables. Thus, structure can also be defined as a group of variables of same or different data types. The variables that are used to store the data are called members of the structure or fields of the structure. In C, the structure is identified by the keyword struct.

The structure definition to hold the student information such as name, roll_number and average_marks can be written as shown below:
struct student
{
char name[10];
int roll_number;
float average_marks;
};

Structure declaration
 As variables are declared before they are used in the function, the structures are also should be declared before they are used.
1. Tagged structures
2. Structure variables
3. Type defined structures

 The structure definition with tag name is called tagged structure. The tag name is the name of the structure. The syntax of tagged structure is shown below:
struct tag_name
{
type1 member1;
type2 member2;
…… ……
…… ……
} ;

What is a structure? What is a structure? Reviewed by Unknown on 08:35 Rating: 5

No comments:

Powered by Blogger.