Hi,
I am making a program to do some simple math.
everything works fine, Addition, Subtraction, Multiplication, and (kinda) Division.
My problem is:
I want to be able to detect if someone is trying to divide by zero, and, if true, move them to an entirely different part of the program.
How does one go about doing this?
Another problem I'm having with the division, is decimal places, it seems to round to the nearest 1, how can i make it round to the nearest, say, thousandth?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int number13, number14;
int answer5;
cout << "number 1? ";
cin >> number13;
cout << "number 2? ";
cin >> number14; //If this =0, redirect to another part of the program (that will yell at the user for doing so)
answer5 = number13 / number14;
cout << "\nAnswer is " << answer5;
printf("\n");
printf("\n");
|
Thanks,
Stephen