#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class stud
{
int rno;
char name[20];
int m1,m2,m3;
public:
void accept(void);
void display(int);
void display();
};
void stud::accept(void)
{
cout<<"\n\nEnter student roll number : ";
cin>>rno;
cout<<"\n\nEnter student name : ";
cin>>name;
cout<<"\n\nEnter marks of 3 subjects : ";
cin>>m1>>m2>>m3;
}
void stud::display(int n)
{
if(rno==n)
{
cout<<"\n\nRoll No. : ";
cout<<rno;
cout<<"\n\nName of student : ";
cout<<name;
cout<<"\n\nMarks of 3 subjects : ";
cout<<m1<<" "<<m2<<" "<<m3;
}
}
void stud:: display()
{
cout<<"\n\nRoll No. : ";
cout<<rno;
cout<<"\n\nName of student : ";
cout<<name;
cout<<"\n\nMarks of 3 subjects : ";
cout<<m1<<" "<<m2<<" "<<m3;
}
int main()
{
int m,ch;
stud S[20];
clrscr();
do
{
cout<<"\n 1.Accept student information";
cout<<"\n 2.Display information of single student";
cout<<"\n 3.Display information of all students";
cout<<"\n 4.Exit";
cout<<"\n\nEnter your choice";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n\nEnetr how many records you want to enter : ";
cin>>m;
for(int i=0;i<m;i++)
{
S[i].accept();
}
break;
case 2:
int r_no;
cout<<"\n\nEnter roll number of student whose information you want to display : ";
cin>>r_no;
for( i=0;i<m;i++)
{
S[i].display(r_no);
}
break;
case 3:
cout<<"\n\nInformation of all students ";
for(i=0;i<m;i++)
{
S[i].display ();
}
break;
case 4:
exit(0);
}
}while(ch!=4);
getch();
return(0);
}

1 Comments

Post a Comment

Previous Post Next Post