Define a class student having all personal information. Also define all necessary function in a class. Find the student having maximum marks using a friend function.
#include<iostream.h>
#include<conio.h>
class student
{
int rno;
int marks;
char nm[80];
public:
friend void max(student *,int)
void getdata()
{
cin>>rno;
cin>>nm;
cin>>marks;
}
void putdata()
{
cout<<rno;
cout<<nm;
cout<<marks<<endl;
}
};
void main()
{
clrscr();
int i,n;
student s[20];
cout<<"how many students=";
cin>>n;
for(i=0;i<n;i++)
s[i].getdata();
max(s,n);
getch();
}
void max(student *s,int n)
{
student m;
m=s[0];
for(int i=0;i<n;i++)
{
if(s[i].marks>m.marks)
m=s[i];
}
m.putdata();
}