diff --git a/main.cpp b/main.cpp index a495fc94..3da5970c 100644 --- a/main.cpp +++ b/main.cpp @@ -7,13 +7,16 @@ int main() std::cout << "Hi, please enter two whole numbers: "; int x,y; - std::cin >> x >> y; std::cout << "Addition: " << x + y << std::endl; std::cout << "Subtraction: " << x - y << std::endl; std::cout << "Multiplication: " << x * y << std::endl; - std::cout << "Division: " << x / y << std::endl; - std::cout << "Remainder: " << x % y << std::endl; + if (y == 0) { + std::cerr << "Cannot divide by zero!\n"; + } else { + std::cout << "Division: " << x / y << std::endl; + std::cout << "Remainder: " << x % y << std::endl; + } std::cout << "Square Root: " << sqrt(x) << std::endl; std::cout << "Square: " << pow(x, y) << std::endl;