#include
void main()
{
int a,b;
clrscr();
cout<<"\nEnter the value a and b:";
cin>>a;
cin>>b;
int x=a-b;
try
{
if(x!=0)
cout<<"\nResult:"<< a/x;
else
throw (x);
}
catch(int i)
{
cout<<"\nException Caught"<< x;
}
getch();
}
Output will be:
Enter the value a and b: 10 10
Exception Caught 0
EXCEPTION HANDLING
Enter the value a and b: 10 5
Result: 2
No comments:
Post a Comment