by Dinesh Thakur Category: Array Pointer and Union

 

#include<iostream.h>

#include<conio.h>
#include<dos.h>
void main ( )
 {
               struct student
           {
               int rn ;
               int sub[10] ;
            };
                 struct student st[50] ;
                 int i, j,n,m,total;
                 float av;
                 clrscr( );
                 cout<<"\n Enter the Number of Students in the Class : ";
                 cin>> n ;
                 cout<<"\nEnter the Number of Subjects Each Student has Taken : " ;
                 cin>> m ;
                 for (i=0;i<n;i++)
                  {
                         total = 0 ;
                         cout<<"\nEnter the Rollno of "<<i+1<<" Student : ";
                         cin>> st[i].rn;
                         cout<<"\nEnter the Marks : ";
                         for (j=0;j<m;j++)
                              {
                                    cout<<"\nEnter the Marks of "<<j+1 <<" Subject : ";
                                    cin>> st[i ].sub[j ];
                                    total = total + st[i ].sub[j ];
                              }
                                    av = (float) total / m ;
                                    cout<<"AVERAGE Marks of "<<i+1<<" Student = "<< av;
                       }
                                    getch();
}

find average marks of N student each having M subjects in a class



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles