Concept
How can the return value communicate errors when roots are passed by reference?
ComputerScienceOne / Quadratic Roots
"We also note that the return value in this case is unused since we are “returning” the root values in the two pass-by-reference variables. This frees up the return value to be used to communicate errors to the calling function. Recall that there could be several “bad” inputs to this function. The roots could be complex values, the coefficient a could be zero, etc. And now that we are dealing with pointers, the pointers could be invalid (point to NULL). In the next chapter, we examine how we can use the return value to communicate different errors to the calling function, letting it handle those errors."
Related Ideas
- How does the Java quadratic roots program check errors and calculate its roots?ComputerScienceOne · Quadratic Roots Revisited
- What section is listed as 2.7?ComputerScienceOne · Quadratic Roots
- How can a C program compute the roots of a quadratic equation?ComputerScienceOne · Computing Quadratic Roots
- How can conditionals handle invalid inputs and special cases in a quadratic roots program?ComputerScienceOne · Quadratic Roots Revisited
- How can conditionals handle invalid inputs and special cases in a quadratic roots program?ComputerScienceOne · Quadratic Roots Revisited