Skip to content

Commit

Permalink
Prevents dividing by 0, resolves ChicoState#61
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaansi committed Feb 1, 2024
1 parent 3abccef commit e83a19c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ int main()
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;
if (y == 0) {
cout << "Dividing by zero is not a number." << std::endl;
} 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;
Expand Down

0 comments on commit e83a19c

Please sign in to comment.