Array of Structure

struct stud
{
          int sno;
          char sname[15];
          int m1,m2,m3;
};

void main()
{
          struct stud s[5];
          int i;

          for(i=0;i<5;i++)
          {
                   printf(“\n Enter No :”);
                   scanf(“%d”,&s[i].sno);
                   fflush(stdin);
                   printf(“\n Enter Name:”);
                   gets(s[i].name);
                   printf(“\n Enter M1 M2 M3:”);
                   scanf(“%d %d %d”,&s[i].m1,&s[i].m2,&s[i].m3);

          }

          for(i=0;i<5;i++)
          {
                   printf(“\n No:%”,s[i].no);
                   printf(“\n Name :%s”,s[i].name);
                   printf(“\n M1  :%d”,s[i].m1);
                   printf(“\n M2 :%d”,s[i].m2);
                   printf(“\n M3 :%d”,s[i].m3);
          }
}

Post a Comment

Previous Post Next Post