What is structure?
A structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling. Structures help to organize complicated data, particularly in large programs, because they permit a group of related variables to be treated as a unit instead of as separate entities.
How to define a structure?
Structure is a user defined data type, it permits logical grouping of related data (of different types) into a single type. A structure is declared using the keyword struct, and the internal organization of the structure is defined by a set of variables enclosed in braces.
Example
Example
struct fraction {
int numerator;
int denominator; // Can’t initialize here
};
How to initialize a structure?
Example
Example