1.2.3 Array and Structure(Array as member of structure & Array of structure)

  • When relation between array and structure is considered, there are two things to consider
    1. Array(s) as member of structure
    2. Array of structure
  • consider the following structure definition

struct student
{
int rno;
char name[10];
int marks[3];
int tot;
};

It consist of 4 members: i)roll number, ii)name, iii)array of marks of three subjects i.e. marks[0] stores marks of subject-1, marks[1] stores marks of subject-2, marks[2] stores marks of subject-3,  and iv)total

  • Now suppose if we want to store result of 10 students, then array of structure variable is defined as follows:

struct student s[10];

Leave a Comment

Your email address will not be published. Required fields are marked *