Code for handling exceptions in C++

#include <iostream>using namespace std;double division(int a, int b){   if( b == 0 )   {      throw "Division by zero condition!";   }   return (a/b);}int main (){int x,y;double z;cout<<"Enter value of x and yn";cin>>x>>y;   try    {     z = division(x, y);     cout << z<<"n";    }catch (const char* msg){     cout << msg << endl;   }   return 0;}



Popular posts from this blog

MATLAB code for Circular Convolution using Matrix method

Positive number pipe in angular 2+