Define a STUDENT class with USN, Name, and Marks in 3 tests of a
subject. Declare an array of 10 STUDENT objects. Using appropriate functions,
find the average of two better marks for each student. Print the USN, Name, and
the average marks of all the students.
#include<iostream.h>
#include<conio.h>
#define SIZE 10
class emp
{
float m1,m2,m3;
char name[20],num[10];
public:
void getdata();
void dispdata();
};
void emp::getdata()
{
cout<<"\nEnter student USN: " ;
cin>>name;
cout<<"Enter student name: " ;
cin>>num;
cout<<"Enter student's 3 marks: " ;
cin>>m1>>m2>>m3;
}
void emp::dispdata()
{
float avg,low=m3;
if(m2<low)
low=m2;
else if(m3<low)
low=m3;
avg=(m1+m2+m3-low)/2;
cout<<"\n student USN: "<<name
<<"\n student name: "<<num
<<"\n student average: "<<avg;
}
void main()
{
clrscr();
emp ob[SIZE];
int n;
cout<<"\n";
cout<<"\n*******************************"
<<"\n Students Report"
<<"\n*******************************"
<<"\n Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
ob[i].getdata();
}
clrscr();
cout<<"\n-----------------"
<<"\nstudents Details::"
<<"\n-----------------";
for( i=0;i<n;i++)
{
cout<<"\n\n student:"<<i+1
<<"\n ----------";
ob[i].dispdata();
}
getch();
}
OUTPUT
No comments:
Post a Comment