Practical - 41
#include<iostream>
using namespace std;
class student{
int eno,cpi;
char name[10];
public:
void getdata()
{
cout<<"\nEnter enrollment no:";
cin>>eno;
cout<<"\nEnter name:";
cin>>name;
c:
try{
cout<<"\nEnter Cpi:";
cin>>cpi;
if(cpi<4)
{
throw cpi;
}
}catch(int i)
{
cout<<"\nCpi "<<i<<" not valid";
goto c;
}
}
void display()
{
cout<<"\n"<<eno<<"\t"<<name<<"\t"<<cpi<<endl;
}
};
int main()
{
student s[10];
int n;
cout<<"\nEnter no of student:";
cin>>n;
for(int i=0;i<n;i++)
{
s[i].getdata();
}
cout<<"\nEno\tName\tCpi";
for(int i=0;i<n;i++)
{
s[i].display();
}
return 0;
}
No comments:
Post a Comment