Created
March 2, 2021 06:26
-
-
Save vineethm1627/21f7b19c22f63d435093ef2840345129 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
try { | |
double num1; | |
cout <<"Enter the first number:"; | |
cin >> num1; | |
double num2; | |
cout <<"Enter the second number:"; | |
cin >> num2; | |
if(num2 == 0.0) { | |
throw 0.0; | |
} | |
cout <<"Result:"<<num1 / num2; | |
} | |
catch(...) { | |
cout <<"You cannot divide any number by zero! Because in ordinary arithmetic, the expression has no meaning, as there is no number which, when multiplied by 0, gives a (assuming a ≠ 0), and so division by zero is undefined."; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To catch exception of any type: