summaryrefslogtreecommitdiff
path: root/5p25.cpp
diff options
context:
space:
mode:
Diffstat (limited to '5p25.cpp')
-rw-r--r--5p25.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/5p25.cpp b/5p25.cpp
new file mode 100644
index 0000000..6a3fbf6
--- /dev/null
+++ b/5p25.cpp
@@ -0,0 +1,37 @@
+#include <iostream>
+#include <stdexcept>
+
+/*
+ *
+ * 5.23
+ *
+ *
+ */
+
+int main () {
+
+ int a = 0;
+ int b = 0;
+ bool d = true;
+ while(d) {
+ d = false;
+ try {
+ std::cin >> a >> b;
+ if(b == 0) {
+ throw std::runtime_error("divide by 0!");
+ }
+
+ std::cout << a / b << std::endl;
+ } catch(std::runtime_error &err) {
+ std::cout << err.what() << "\nTry again? Y/N " << std::endl;
+ char c = 0;
+ std::cin >> c;
+ if(c == 'Y' || c == 'y') {
+ d = true;
+ }
+ }
+
+ }
+
+ return 0;
+}