Skip to content
Snippets Groups Projects
Commit 78fca4d7 authored by Christian Wunder's avatar Christian Wunder
Browse files

Fixed division by 0 fixed.

parent 32d8bed6
No related branches found
No related tags found
1 merge request!2Fixed division by 0 fixed.
......@@ -6,7 +6,12 @@
int plus( int a, int b) { return a + b; }
int minus( int a, int b) { return a - b; }
int multiply(int a, int b) { return a * b; }
int divide( int a, int b) { return a / b; }
int divide( int a, int b) {
if(b == 0) {
throw std::invalid_argument("Division by 0.");
}
return a / b;
}
int pop_stack(auto &stack) {
const auto ret{stack.top()};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment