Array Structure In C

Array Structure Definition

Declaring an array of structure is same as declaring an array of fundamental types. Since an array is a collection of elements of the same type. In an array of structures, each element of an array is of the structure type.

Declaring array of Structure

struct Employee
{
  int age;
  char name[50];
  int salary;
} Employees[4] = {
                 {25, "Suresh", 25000},
                 {24, "Tutorial", 28000},
                 {22, "Gateway", 35000},
                 {27, "Mike", 20000}
                 };

Here, Employee structure is used for storing the employee details such as age, name and salary. We created the array of structures variable Employees [4] (with size 4) at the declaration time only. We also initialized the values of each and every structure member for all the 4 employees.

Example



Output:

 Records of STUDENT : 1
 Id is: 1
 Name is: Raju
 Percentage is: 86.500000
 
 Records of STUDENT : 2
 Id is: 2
 Name is: Surendren
 Percentage is: 90.500000
 
 Records of STUDENT : 3
 Id is: 3
 Name is: Thiyagu
 Percentage is: 81.500000