A program to demonstrate the concept of exception handling class in C++

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
float a, b, c;
try
{
cout<<“enter the value of a and b:”;
cin>>a>>b;
if(b==0)
{
throw(b);
}
c=a/b;
cout<<“Quotient=”<<c;
}
catch(float a)
{
cout<<“not divisible”;
}
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *