0
What is a Arrays of Structures

Subject : Structured Programming Approach

Title : Arrays, String, Structures and Union

Marks : 4M

mumbai university spa(82) • 174  views
0  upvotes
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;
0  upvotes
Please log in to add an answer.

Next up

Read More Questions

If you are looking for answer to specific questions, you can search them here. We'll find the best answer for you.

Search

Study Full Subject

If you are looking for good study material, you can checkout our subjects. Hundreds of important topics are covered in them.

Know More