Structure can store many information of different data types.Collection of structures is known as array of structure.
#include struct student { int rollno; char name[10]; }; void main() { int i; struct student s[2]; printf("Enter Records of 2 students"); for(i=0;i<2;i++) { printf("\n Enter Rollno:"); scanf("%d",&s[i].rollno); printf("\n Enter Name:"); scanf("%s",&s[i].name); } printf("\n Student Informations :"); for(i=0;i<2;i++) { printf("\n Rollno:%d, Name:%s",s[i].rollno,s[i].name); } }
Output
Enter Records of 2 students
Enter Rollno:1
Enter Name:Rahul Bisht
Enter Rollno:2
Enter Name:Rohit Kumar
Student Informations:
Rollno:1, Name:Rahul Bisht
Rollno:2, Name:Rohit Kumar