(Algebra: solve quadratic equations) The two roots of a quadratic equation ax? + bx + x = 0 can be obtained using the following formula: -b + VB - 4ac -b - Vb - 4ac and r2 2a 2a Write a function with the following header void solveQuadraticEquation(double a, double b, double c, double& discriminant, double& rl, double& r2) b² - 4ac is called the discriminant of the quadratic equation. If the discriminant is less than 0, the equation has no roots. In this case, ignore the value in rl and r2. Write a test program that prompts the user to enter values for a, b, and c and dis- plays the result based on the discriminant. If the discriminant is greater than or equal to 0, display the two roots. If the discriminant is equal to 0, display the one root. Otherwise, display "the equation has no roots". See Programming Exercise 3.1 for sample runs.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.3: Using Mathematical Library Functions
Problem 1E
icon
Related questions
Question
(Algebra: solve quadratic equations) The two roots of a quadratic equation
ax? + bx + x = 0 can be obtained using the following formula:
-b + VB - 4ac
-b - Vb - 4ac
and r2
2a
2a
Write a function with the following header
void solveQuadraticEquation(double a, double b, double c,
double& discriminant, double& rl, double& r2)
b² - 4ac is called the discriminant of the quadratic equation. If the discriminant
is less than 0, the equation has no roots. In this case, ignore the value in rl and
r2.
Write a test program that prompts the user to enter values for a, b, and c and dis-
plays the result based on the discriminant. If the discriminant is greater than or
equal to 0, display the two roots. If the discriminant is equal to 0, display the one
root. Otherwise, display "the equation has no roots". See Programming
Exercise 3.1 for sample runs.
Transcribed Image Text:(Algebra: solve quadratic equations) The two roots of a quadratic equation ax? + bx + x = 0 can be obtained using the following formula: -b + VB - 4ac -b - Vb - 4ac and r2 2a 2a Write a function with the following header void solveQuadraticEquation(double a, double b, double c, double& discriminant, double& rl, double& r2) b² - 4ac is called the discriminant of the quadratic equation. If the discriminant is less than 0, the equation has no roots. In this case, ignore the value in rl and r2. Write a test program that prompts the user to enter values for a, b, and c and dis- plays the result based on the discriminant. If the discriminant is greater than or equal to 0, display the two roots. If the discriminant is equal to 0, display the one root. Otherwise, display "the equation has no roots". See Programming Exercise 3.1 for sample runs.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning