dividing by 0 problem

Apr 4, 2009 at 3:44pm
Why even if I placed the condition

if (y==0)
cout << "Error!";

my function keeps calculating the division even if it does diplay "Error!" as I want??
Last edited on Apr 18, 2009 at 5:33pm
Apr 4, 2009 at 4:01pm
You should return a value also when y==0
Apr 5, 2009 at 9:07am
Ok i understand...what I need to do when y==0 is to display the error and then prompt the user if he wants to continue...if they type yes then they will get to input another 2 numbers, if they type no then the program will stop.
If I add return 0; for y==0 I do get the Error message displayed but I also get a 0 displayed and the program stops...

can someone help me to understand how to proceed?

Last edited on Apr 18, 2009 at 5:33pm
Apr 5, 2009 at 9:20am
continue getting the numbers until y is not equal to 0
( do - while )
Topic archived. No new replies allowed.