Sankar™ -Dark ray Admin
Number of posts : 1067 Age : 33 Registration date : 2007-12-12
| Subject: ~~Lab ~~ Mon Sep 07, 2009 10:53 pm | |
| | |
|
Sankar™ -Dark ray Admin
Number of posts : 1067 Age : 33 Registration date : 2007-12-12
| Subject: Re: ~~Lab ~~ Mon Sep 07, 2009 10:53 pm | |
| #include #include class student { public: int reg,m[5],tot; public: void setData(int r); int getTotal() { tot=m[0]+m[1]+m[2]+m[3]+m[4]; return(tot); } }; void student:: setData(int r) { reg=r; cout<<"Enter marks of 5 subjects\n"; for(int j=0;j<5;j++) { cin>>m[j]; } } void main() { student s[5]; int mark[5],i,r,r1,r2,h,l,avg=0; clrscr(); for(i=0;i<5;i++) { cout<<"\nEnter the registration number \n"; cin>>r; s.setData(r); s.tot=s.getTotal(); cout<<"\nTotal os student "<< s.reg<<" is "<.tot; } h=s[1].tot; l=s[1].tot; for(i=0;i<5;i++) { if(s.tot>h) { h=s.tot; r1=i; } if(s.tot.tot; r2=i; } } cout<<"The class highest is"<.tot; } avg=avg/5; cout<<"The class average is "<getch(); } | |
|