/* C program to create array of structures */
struct student
{
char name[30];
char group[30];
char number[30];
float grade;
};
main()
{
struct student s[6];
int i;
for(i=0;i<6;i++) /* reading six student details at a time implementing array of structures */
{
printf("\n enter the student %d name, group, number and roll number",i);
scanf("%s%s%s%f",&s[i].name,&s[i].group,&s[i].number,&s[i].grade);
}
for(i=0;i<6;i++) /* displaying six student details at a time implementing array of structures */
{
printf("\n\n %s\t%s\t%s\t%f",s[i].name,s[i].group,s[i].number,s[i].grade);
}
}
OUTPUT"
enter student 1 detail
ashok MCA 101 A
enter student 2 detail
nani MCA 102 A
enter student 3 detail
kumar MCA 103 B
enter student 4 detail
raju MCA 104 A
enter student 5 detail
suresh MCA 105 A
enter student 6 detail
geetha MCA 101 A
ashok MCA 101 A
nani MCA 102 A
kumar MCA 103 B
raju MCA 104 A
suresh MCA 105 A
geetha MCA 101 A
No comments:
Post a Comment