Exception handling
#include<iostream> using namespace std; int main(){ int a = 10 ,b = 10,c = 20; float d; try{ if((a-b)!=0){ d=c/(a-b); cout<<"Result is : "<<d; }else{ throw(a-b); } }catch(int i){ cout<<"Infinte values can't be printed because a-b is:"<<i; } }
Infinte values can't be printed because a-b is:0
Comments :