Array within Structure

struct stud
{
          int sno;
          char sname[15];
          int m[3];
};

void main()
{
          struct  stud s[5];
          int i,j;
         
          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);
         
                   for(j=0;j<3;j++)
                   {
                             printf(“\n Enter mark :”);
                             scanf(“%d”,&s[i].m[j]);
                   }

          }

for(i=0;i<5;i++)
{
                   printf(“\n  No :%d”,s[i].sno);
                   printf(“\n Name :%s”,s[i].sname);

                   for(j=0;j<3;j++)
                   {
                             printf(“Mark - %d = %d “,j+1,s[i].m[j]);
                   }
}

}

Post a Comment

Previous Post Next Post