diff --git a/main.cpp b/main.cpp index a495fc94..9206e9bb 100644 --- a/main.cpp +++ b/main.cpp @@ -8,14 +8,23 @@ int main() 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; - std::cout << "Square Root: " << sqrt(x) << std::endl; - std::cout << "Square: " << pow(x, y) << std::endl; + cin >> x >> y; + + cout << "Addition: " << x + y << endl; + cout << "Subtraction: " << x - y << endl; + cout << "Multiplication: " << x * y << endl; + if (y==0) { + cout << "Dividing by 0 is not a number" << endl; + } else { + cout << "Division: " << x / y << endl; + cout << "Remainder: " << x % y << endl; + } + if (x<0) { + cout << "Square root of a negative number is not a number" << endl; + } else { + cout << "Square Root: " << sqrt(x) << endl; + } + cout << "Square: " << pow(x, y) << endl; return 0; }