8. (A) Show the implementation of exception handling
| ||
Void main() | ||
{ | ||
int a,b; | ||
cout<<”enter values of a and b”; | ||
cin>>a>>b; | ||
int x=a-b; | ||
try | ||
{ | ||
If(x!=0) | ||
{ | ||
cout<<”result(a/x)=”<<a/x<<”\n”; | ||
} | ||
Else | ||
{ | ||
throw(x); | ||
} | ||
} | ||
catch(int i) | ||
{ | ||
Cout<<”exception caught:x=”<<x<<”\n”; | ||
} | ||
cout<<”end”; | ||
} |
8. (A) Show the implementation of exception handling
Reviewed by admin
on
December 23, 2019
Rating:
No comments: