Program that display average of marks for each subject


#include <iostream.h>
#include <conio.h>
void main ( )
    {
        int i , j ;
        int marks[3][5] ={ {65,68,75,59,77},
                           {62,85,57,66,80},
                           {71,77,66,63,86} } ;
        float avg ;
        cout<<" \n\t\t ";
        for (i = 0 ; i < 5 ; i++)
            cout<<"subj"<<i+1<<"\t";

        cout<<"\n" ;
        for (i=0 ; i<3 ; i++)
        {
            cout<<" student"<<i+1<<"\t";
            for(j=0 ; j<5 ; j++)
                cout<<marks[i][j]<<"\t";
            cout<<" \n ";
        }
        cout<< "\n\nThe Average of each subject is : \n" ;

        for (j=0 ; j<5 ; j++)
        {
            cout<<"Subject"<<j+1<<" : " ;

            for (i=0,avg=0 ; i<3 ; i++)
                avg = avg + float(marks[i][j]) ;

            avg = avg / 3 ;
                               cout.precision(2);
            cout<<avg<<"\n";
        }
        getch () ;
    }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|