Array of structures program in c
#include<stdio.h> #include<conio.h> struct student { char name[20]; int roll_no; char clas[10]; char dob[10]; }; int main() { struct student s1[20]; int i,n; printf("How many student information you will be enter:-"); scanf("%d",&n); for(i=1;i<=n;i++) { printf("\nEnter no. %d student information\n",i); fflush(stdin); printf("Name\t:-"); gets(s1[i].name); printf("Roll No.\t:-"); scanf("%d",&s1[i].roll_no); printf("Class\t:-"); scanf("%s",s1[i].clas); printf("Date of birth\t:-"); scanf("%s",s1[i].dob); } printf("\nEntered student information\n"); for(i=1;i<=n;i++) { printf("\nName\t:-%s\n",s1[i].name); printf("Roll No.\t:-%d\n",s1[i].roll_no); printf("Class\t:-%s\n",s1[i].clas); printf("Date of birth\t:-%s\n\n",s1[i].dob); } getch(); return 0; }Output:-
0 Comments