This section illustrates you the concept of structure in C.
Structures in C defines the group of contiguous (adjacent) fields, such as records or control blocks. A structure is a collection of variables grouped together under a single name. It provides an elegant and powerful way for keeping related data together.
Once the structure is defined, you can declare a structure variable by preceding the variable name by the structure type name. In the given example, a small structure i.e struct is created student and declared three instances of it as shown below.
In structures, we have assigned the values to the instances i.e, id, name, percentage in the following way:
student2.name = "Angelina";
student3.percentage = 90.5;
Here is the code:
Output will be displayed as:
Posted on: February 6, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles