You are on page 1of 2

//Name: shubham swami

//Class: SE Div: C
//Roll No.: 43
//XCEPTION HANDLING

#include<iostream>
class excp
{
double no1,no2;
public:
void getdata()
{
cout<<"\nEnter the First Double Value :";cin>>no1;
cout<<"\nEnter the Second Double Value :";cin>>no2;
}
void division()
{
cout<<"\nDivision Result :"<<(no1/no2);
}
void displaydivision()
{
try
{
if(sizeof(no1)<2 || sizeof(no2)<2)
throw no1;
else
{
if(no2==0)
throw no2;
else
division();

}
catch(char x)
{
cout<<"\nException : Character Input :"<<x;
}
catch(double y)
{
cout<<"\nException : DIVIDE BY ZERO :"<<y;
}
}

};
int main()
{
excp a,b;
a.getdata();
a.displaydivision();
b.getdata();
b.displaydivision();
return 0;

OUTPUT
Enter the First Double Value :3

Enter the Second Double Value :0

Exception : DIVIDE BY ZERO :0


Enter the First Double Value :3

Enter the Second Double Value :2

Division Result :1.5

You might also like