Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //
  2. // Created by William Smith on 4/18/17.
  3. //
  4.  
  5. #define NDEBUG
  6.  
  7. #include <iostream>
  8. #include <cassert>
  9.  
  10.  
  11. using namespace std;
  12.  
  13. double division(int a, int b) {
  14. if( b == 0 ) {
  15. throw "Division by zero condition!";
  16. }
  17. return (a/b);
  18. }
  19.  
  20. int main () {
  21. int x = 50;
  22. int y = 0;
  23. double z = 0;
  24.  
  25. assert(y>0);
  26.  
  27. try {
  28. z = division(x, y);
  29. cout << z << endl;
  30. }catch (const char* msg) {
  31. cerr << msg << endl;
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement