Search This Blog

Sunday, 23 August 2020

Exception handling

 #include<iostream>

using namespace std;

int main()

{

int a,b;

cout<<"\n\n\tEnter the values of a & b :";

cin>>a>>b;

int x=(a-b);

try 

{

if(x!=0)

{

cout<<"\n\n\tResult = "<<(a/(a-b));

}

else

{

throw(x);

}

}

catch(int i)

{

cout<<"\n\n\tDivision by zero :";

}


return 0;

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts