# Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

## Structure having Integer Array as Member

1. Structure may contain the Array of integer as its Member.
2. Let us discuss very familiar example of student , We can store name,roll,percent as structure members , but sometimes we need to store the marks of three subjects then we embed integer array of marks as structure member

Example :Structure

```struct student
{
char sname[20];
int roll;
float percent;
int marks[3];     //Note Carefully
}s1;```

### Access marks of Student s1 :

```Access Subject 1 Marks : s1.marks[0]
Access Subject 2 Marks : s1.marks[1]
Access Subject 3 Marks : s1.marks[2]```

## Live Example :

```#include <stdio.h>

struct student
{
char sname[20];
int marks[3];     //Note Carefully
}s1;

int main()
{

printf("
Enter the Name of Student : ");
gets(s1.sname)

printf("
Enter the Marks in Subject 1 : ");
scanf("%d",&s1.marks[0]);
printf("
Enter the Marks in Subject 2 : ");
scanf("%d",&s1.marks[1]);
printf("
Enter the Marks in Subject 3 : ");
scanf("%d",&s1.marks[2]);

printf("
----  Student Details -------- ");
printf("
Name of Student    : %s",s1.sname);
printf("
Marks in Subject 1 : %d",s1.marks[0]);
printf("
Marks in Subject 2 : %d",s1.marks[1]);
printf("
Marks in Subject 3 : %d",s1.marks[2]);

return 0;
}
```

## Explanation of the Code :

marks[3] array is created inside the structure then we can access individual array element from structure using structure variable. We even can use for loop to accept the values of the Array Element from Structure.