Program using class to -accept details of all students -to display details of one student -to display details of all students
#include<iostream.h>
#include<conio.h>
class student
{
public:
int rollno,m1,m2,m3;
char name[10];
int i;
void accept();
void display();
void display(int);
};
void student:: display( int r)
{
if(rollno==r)
{
cout<<"Rollno" <<" "<<"name"<<" " <<"marks"<<" "<<"marks"<<" "<<"marks"<<endl;
cout<< rollno <<" "<<name<<" "<<m1<<" "<<m2<<" "<<m3<<endl;
}
}
void student :: accept()
{
cout<<"\nEnter the rollno\n";
cin>>rollno;
cout<<"\nEnter the name of the student\n";
cin>>name;
cout<<"\nEnter the marks of C\n";
cin>>m1;
cout<<"\nEnter the marks of C++\n";
cin>>m2;
cout<<"\nEnter the marks of Java\n";
cin>>m3;
}
void student::display()
{
cout<<"\nthe rollno is \t"<<rollno;
cout<<"\nname of the student \t"<<name;
cout<<"\nthe marks of C \t"<<m1;
cout<<"\nthe marks of C++ \t"<<m2;
cout<<"\nthe marks of Java \t"<<m3<<endl;
}
void main()
{ int ch;
int i;
student s[3],s1;
int rollno; char name[10];int m1,m2,m3;
clrscr();
do
{
cout<<endl<<"Enter details of all student";
cout<<endl<<"Display details of one student";
cout <<endl<<"enter your choice";
cin>>ch;
switch(ch)
{ case 1: cout<<"Details of all students";
for(i=0;i<3;i++)
{
s[i].accept();
}
for(i=0;i<3;i++)
{
s[i].display();
}
break;
case 2:
int r;
cout<<"enter the roll no :\n";
cin>>r;
cout<<"Details of one student"<<endl;
for(i=0;i<3;i++)
{
s[i].display(r);
}
break;
default:cout<<"Invalid choice";
}
}while(ch<=2);
getch();
}
#include<iostream.h>
#include<conio.h>
class student
{
public:
int rollno,m1,m2,m3;
char name[10];
int i;
void accept();
void display();
void display(int);
};
void student:: display( int r)
{
if(rollno==r)
{
cout<<"Rollno" <<" "<<"name"<<" " <<"marks"<<" "<<"marks"<<" "<<"marks"<<endl;
cout<< rollno <<" "<<name<<" "<<m1<<" "<<m2<<" "<<m3<<endl;
}
}
void student :: accept()
{
cout<<"\nEnter the rollno\n";
cin>>rollno;
cout<<"\nEnter the name of the student\n";
cin>>name;
cout<<"\nEnter the marks of C\n";
cin>>m1;
cout<<"\nEnter the marks of C++\n";
cin>>m2;
cout<<"\nEnter the marks of Java\n";
cin>>m3;
}
void student::display()
{
cout<<"\nthe rollno is \t"<<rollno;
cout<<"\nname of the student \t"<<name;
cout<<"\nthe marks of C \t"<<m1;
cout<<"\nthe marks of C++ \t"<<m2;
cout<<"\nthe marks of Java \t"<<m3<<endl;
}
void main()
{ int ch;
int i;
student s[3],s1;
int rollno; char name[10];int m1,m2,m3;
clrscr();
do
{
cout<<endl<<"Enter details of all student";
cout<<endl<<"Display details of one student";
cout <<endl<<"enter your choice";
cin>>ch;
switch(ch)
{ case 1: cout<<"Details of all students";
for(i=0;i<3;i++)
{
s[i].accept();
}
for(i=0;i<3;i++)
{
s[i].display();
}
break;
case 2:
int r;
cout<<"enter the roll no :\n";
cin>>r;
cout<<"Details of one student"<<endl;
for(i=0;i<3;i++)
{
s[i].display(r);
}
break;
default:cout<<"Invalid choice";
}
}while(ch<=2);
getch();
}