dividing by 0 problem

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
You should return a value also when y==0
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
continue getting the numbers until y is not equal to 0
( do - while )
Topic archived. No new replies allowed.