TRY AND CATCH BLOCK WITH THE STRING

 #include<iostream>

using namespace std;

int main()

{

    int a,b;

 cout<<"enter two number"<<"\n";

 cin>>a;

 cin>>b;

 try

 {

     if(b==0)

        throw "DIVISION BY ZERO ERROR";


 cout<<"result "<<a/b<<"\n";

  cout<<"SUCCESS";

 }


 catch(const char *ch)

{

    cout<<"error ocuured "<<ch;

}

}

Comments

Popular posts from this blog

TRY AND CATCH BLOCK WITH THE NUMBER