fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a = 10, b = 0;
  6.  
  7. try {
  8. if (b == 0)
  9. throw b; // throw exception
  10. cout << a / b;
  11. }
  12. catch (int x) {
  13. cout << "Division by zero error";
  14. }
  15.  
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Division by zero error