recent

Array of Structures in C

Array of Structures in C

#include<stdio.h>

struct student{

int roll;
char name[20];
};

main()

{
int i;

struct student st[5];

for(i=0;i<5;i++)

{

printf("Enter student %d roll no:\n",i+1);
scanf("%d",&st[i].roll);

printf("Enter student %d name:\n",i+1);
scanf("%s",st[i].name);

}

printf("Student details is here:\n\n");

for(i=0;i<5;i++)

{

printf("Student %d:\nRoll no: %d\nName: %s\n\n",i+1,st[i].roll,st[i].name);

}

}
Powered by Blogger.