calculate average marks of five students using array of structure in c.

#include<stdio.h>
        struct student
        {
          int sub1;
          int sub2;
          int sub3;
          int sub4;
          int sub5;
        };
            void main()
        {
             struct student s[10];
             int i,j,fn,sum=0,total=0;
             float a;
             for(i=0;i<=4;i++)
                 {
                        printf("\nEnter Marks in five Subjects = ");
                        scanf("%d%d%d%d%d",& s[i].sub1,&s[i].sub2,&s[i].sub3,&s[i].sub4,&s[i].sub5);
                        total=s[i].sub1+s[i].sub2+s[i].sub3+s[i].sub4+s[i].sub5;
                        printf("\nTotal marks of s[%d] Student= %d\n",i,total);
                        a=total/5;
                        printf(" average marks of five subject= %f\n",a);

                 }
                 for(j=0; j<=4; j++)
                 {
                     sum=sum+total;
                 }
                 fn=sum/5;
                 printf("average of five students : %d\n",fn);

                        getch();
         }


Comments

Popular posts from this blog

Display name of five students using structure in c.

C++ for banking transaction demo