0
1.5kviews
What is a Arrays of Structures
1 Answer
0
23views

We use structure to describe the format of a number of related variables. For example, in analyzing the marks obtained by a class of students, we may use a template to describe student name and marks obtained in various subjects and then declare all the students as structure variables. In such cases, we may declare an array of structure, each elements of the array representing a structure variable. For example,

struct class student[100];

It defines an array called student that consists of 100 elements. Each element is defined to be of the type struct class. Consider the following declaration:

struct marks
{
int subject1; 
int subject2; 
int subject3; 
 }; 
main() 
{ 
static struct marks student[3] = { {45, 68, 81}, {75, 53, 69}, {57,36,71} };
}

This declares the student as an array of three elements students[0], student[1], and student[2] and initializes their members as follows:

student[0].subject1=45;
student[0].subject2=68; 
…………. 
………….
student[2].subject3=71;
Please log in to add an answer.