Error in function?

.
Last edited on
1
2
3
4
5
if (b == 0)
{
      std::cout << "Error! Cannot divide by zero!";
      return 0.0
}


Make sense?
Yeah it makes sense but I don't understand where I put that in the code I have to make it work. I'm new and really can't tell the where the positions of many things should be going..
It's just simple logic:

You enter the function and you check if b ISN'T equal to 0. If it indeed isn't, you return the number that results from the math.

OTHERWISE (which is your else statement), is ONLY triggered if b IS 0. So you should output the error with your ELSE statement.
You want help don't edit your posts and delete the contents. Doing so is rude and makes people avoid helping you.
Topic archived. No new replies allowed.