Divide using try catch

Description:

The user will enter numerator and denominator. If the denominator is zero, an exception will be generated using throw statement and the denominator will be passed as parameter with the exception. The only catch block we have accepts integer parameter, hence the control will be shifted to this block and the statements in the catch block will be executed Test Case 1 Input (stdin) 16 8 Expected Output The result of division is:2 Test Case 2 Input (stdin) 8 0 Expected Output You cannot enter 0 in denominator

Program :

#include <iostream>

using namespace std;

int main()

{

int a,b,c;

  cin>>a>>b;

  if(b==0)

    cout<<"You cannot enter "<<c<<" in denominator";

  else

  {

    c=a/b;

  cout<<"The result of division is:"<<c;

  }

return 0;

}