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]; cout<<"Enter Records of 2 students"; for(i=0;i<2;i++) { cout<<"Enter Rollno:"; cin>>s[i].rollno; cout<<"\n Enter Name:"; cin>>s[i].name; } cout<<"\n Student Informations :"; for(i=0;i<2;i++) { cout<<"\n Rollno: "<< s[i].rollno; cout<<"\n Name:" << 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