11. Create a class student containing data members: – Rollno – name -marks1, marks2, marks3 Write necessary member functions: 1. to accept details of all students 2. to display details of one student 3. to display details of all students(Use Function overloading).


#include<iostream.h>
#include<conio.h>
class stud
{
public: int rno;
char name[20];
int m1,m2,m3;
public:
void details()
{
cout<<“\nROLL_NO NAME MARKS THREE SUBJECT \n”;
cin>>rno>>name>>m1>>m2>>m3;
}
void details(int nm)
{
cout<<“\nDetails of ONE student :\n”;
cout<<“\nROLL_NO\tNAME\tMARK1\tMARK2\tMARK3 \n”;
cout<<“=====================================\n” ;
cout<<nm<<“\t”<<name<<“\t”<<m1<<“\t”<<m2<<“\t”<<m3<<endl<<“\n\n”;
}
void details(char*)
{
cout<<rno<<“\t”<<name<<“\t”<<m1<<“\t”<<m2<<“\t”<<m3<<endl;
}
};
void main()
{
int rn,i,n;
stud s[20];
clrscr();
cout<<“How many student inform: \n”;
cin>>n;
for(i=0;i<n;i++)
{
s[i].details();
}
cout<<“Enter the roll number:\n “;
cin>>rn;
for(i=0;i<n;i++)
{
if(rn==s[i].rno)
{
s[i].details(rn);
}
}
cout<<“Details of all student: \n”;
cout<<“ROLL_NO\tNAME\tMARK1\tMARK2\tMARK3 \n\n”;
cout<<“=====================================\n” ;
for(i=0;i<n;i++)
{
s[i].details(s[i].name);
}
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s