Skip to content

Commit

Permalink
made more verbose messages and handled divide by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshfollmer committed Jan 31, 2024
1 parent 3abccef commit c9c6763
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ 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;
std::cout << x << " + " << y << " = " << x+y << std::endl;
std::cout << x << " - " << y << " = " << x-y << std::endl;
std::cout << x << " * " << y << " = " << x*y << std::endl;
if(y == 0)
{
std::cout << "Dividing by 0 is not a number"
}
else
{
std::cout << x << " / " << y << " = " << x/y << "with a remainder of " << x % y << std::endl;
}

std::cout << "Square Root of " << x << " is " << sqrt(x) << std::endl;
std::cout << "Square Root of " << y << " is " << sqrt(y) << std::endl;
std::cout << x << "^" << y << "=" << pow(x, y) << std::endl;

return 0;
}

0 comments on commit c9c6763

Please sign in to comment.