Structure in array an example
#include<stdio.h>
#include<conio.h>
struct student
{
char name[20];
int regno,m;
};
void main()
{
struct student s[100];
int n,i;
clrscr();
printf("\n How many student\n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n Enter the name of student\n\n");
scanf("%s",s[i].name);
printf("\nEnter the regester no of student\n\n");
scanf("%d",&s[i].regno);
printf("\nEnter total mark");
scanf("%d",&s[i].m);
}
clrscr();
printf("\n\nName\tRegno.\ttotal mark\t");
for(i=0;i<n;i++)
{
printf("\n%s\t%d\t%d",s[i].name,s[i].regno,s[i].m );
}
getch();
}
|