Skip to content

Commit

Permalink
Fixes ChicoState#61 divide by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsharland committed Feb 7, 2024
1 parent 3abccef commit b1a99e1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@

int main()
{
cout << "This is Kevin!\n";
cout<<"Hi, please enter two whole numbers: ";
std::cout << "This is Kevin!\n";
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 << "Division: ";
if(y) {std::cout << x / y;}
else{ std::cout << "NaN";}
std::cout << 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 b1a99e1

Please sign in to comment.