Perform division operation use general purpose catch block with parameters which shows it will catch all the exceptions. Now if the denominator is 0 or negative, in both the cases the generalized catch block will be executed and the statement There is a problem performing calculation. Check your input again will be printed. Test Case 1 Input (stdin) 50 10 Expected Output The result of division is:5 Test Case 2 Input (stdin) 10 0 Expected Output There is a problem performing calculation.Check your input again
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
if(b==0)
cout<<"There is a problem performing calculation.Check your input again";
else
{
c=a/b;
cout<<"The result of division is:"<<c;
}
return 0;
}