logo CodeStepByStep logo


Author: Marty Stepp (on 2016/06/19)

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

Type your C++ solution code here:

This is a function problem. Write a C++ function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.