logo CodeStepByStep logo

quadratic

Write a function named quadratic that computes roots of quadratic equations. Recall that a quadratic equation is one of the form, ax2 + bx + c = 0. Your function accepts five parameters: The integer coefficients a, b, and c, and two real number references root1 and root2. Your function should compute the two integer roots of the quadratic equation and store them into the two reference parameters. For example, the equation x2 - 3x - 4 = 0 has roots of x = 4 and x = -1, so the call of quadratic(1, -3, -4, root1, root2); should set root1 to 4 and root2 to -1. You may assume that the function has two real roots. Recall the quadratic formula:

quadratic formula

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.