Question: What is a Arrays of Structures
0

Subject : Structured Programming Approach

Title : Arrays, String, Structures and Union

Marks : 4M

mumbai university spa(82) • 149 views
ADD COMMENTlink
modified 11 months ago  • written 11 months ago by gravatar for Abhishek Tiwari Abhishek Tiwari ♦♦ 50
0

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;
ADD COMMENTlink
written 11 months ago by gravatar for Abhishek Tiwari Abhishek Tiwari ♦♦ 50
Please log in to add an answer.