Back To C++ Structures
//program to create a structure student and creating array of structure of 3 variables (example of array of structure variables) #include
#include
struct student { int rollno; char name[20]; int marks; }; void main() { struct student s[3]; int i; clrscr(); for(i=0;i<3;i++) { printf("\nenter rollno of student %d : ",i+1); scanf("%d",&s[i].rollno); printf("\nenter name of student %d : ",i+1); scanf("%s",s[i].name); printf("\nenter marks of student %d : ",i+1); scanf("%d",&s[i].marks); } printf("\ndisplaying the values \n"); for(i=0;i<3;i++) { printf("\nrollno of student %d is %d ",i+1,s[i].rollno); printf("\nname of student %d is %s ",i+1,s[i].name); printf("\nmarks of student %d is %d ",i+1,s[i].marks); } getch(); }