diff --git a/except string.cpp b/except string.cpp new file mode 100644 index 0000000..ca25b35 --- /dev/null +++ b/except string.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +int main(){ + int num; + + cin>>num; + + try{ + if(num == 0){ + throw("Zero"); + } + + else if (num <0){ + throw("Negative"); + } + + else{ + cout<<"All good number is positive"; + } + } + + catch(const char *err){ + cout<<"There was an error nigga. Number is "< +using namespace std; + +int main(){ + int num,den; + + try{ + cin>>num>>den; + if(den == 0){ + throw(den); + } + + else{ + cout<<(num/den); + } + } + + catch(int x){ + cout<<"Denominator cannot be zero"; + } + + return 0; +} diff --git a/exception handling.exe b/exception handling.exe new file mode 100644 index 0000000..cba1f64 Binary files /dev/null and b/exception handling.exe differ diff --git a/hr.exe b/hr.exe index abeaaf7..230c4b0 100644 Binary files a/hr.exe and b/hr.exe differ