In this question, you are asked to write a program that finds the roots of any quadratic equation. The program requests the user to insert the three coefficients a, b, and c, respectively and outputs the values of the roots as follows: • If there are two real different roots, the program prints the root x1 then the root X2 2 with a single space between them. • If there is a single real root, the program prints the root only once. If there are two complex different roots, the program prints the root ₁ then the root x2 on a new line.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

write a c++ code please test it

Quadratic equations are the polynomial
equations of degree 2 in one variable of type
f(x) = ax²+bx+c. Where a, b, c, ER and
a * 0. It is the general form of a quadratic
equation where 'a' is called the leading
coefficient and 'c' is called the absolute term of
f(x).
The roots of a quadratic equation are the
values of the variable that satisfy the equation.
They are also known as the "solutions" or
"zeros" of the quadratic equation. For example,
the roots of the quadratic equation
x²7x + 10 are *₁ = 2 and ₂
- 5
because they satisfy the equation (i.e. when
each of them is substituted in the given
equation we get 0).
The first step to solve the equation is to find
the determinant which equals 6² 4ac. Based
on the determinant value, we have three
possibilities for the equation roots:
●
If determinant > 0, the equation has two
real and different roots which are:
x1 =
and
-b-√determinant
2a
-b+√determinant
x2 =
2a
If determinant = 0, the equation has one
-b
real root which is: x =
2a
• If determinant < 0, then the equation has
two complex (i.e. not real) roots which
✓determinant
-i and
2a
are: x1 =
-b
2a
X2
=
-b
2a
determinant
2a
•
∙i.
In this question, you are asked to write a
program that finds the roots of any quadratic
equation. The program requests the user to
insert the three coefficients a, b, and c,
respectively and outputs the values of the
roots as follows:
• If there are two real different roots, the
program prints the root ₁ then the root
2 with a single space between them.
• If there is a single real root, the program
prints the root only once.
• If there are two complex different roots,
the program prints the root ₁ then the
root x2 on a new line.
)
Transcribed Image Text:Quadratic equations are the polynomial equations of degree 2 in one variable of type f(x) = ax²+bx+c. Where a, b, c, ER and a * 0. It is the general form of a quadratic equation where 'a' is called the leading coefficient and 'c' is called the absolute term of f(x). The roots of a quadratic equation are the values of the variable that satisfy the equation. They are also known as the "solutions" or "zeros" of the quadratic equation. For example, the roots of the quadratic equation x²7x + 10 are *₁ = 2 and ₂ - 5 because they satisfy the equation (i.e. when each of them is substituted in the given equation we get 0). The first step to solve the equation is to find the determinant which equals 6² 4ac. Based on the determinant value, we have three possibilities for the equation roots: ● If determinant > 0, the equation has two real and different roots which are: x1 = and -b-√determinant 2a -b+√determinant x2 = 2a If determinant = 0, the equation has one -b real root which is: x = 2a • If determinant < 0, then the equation has two complex (i.e. not real) roots which ✓determinant -i and 2a are: x1 = -b 2a X2 = -b 2a determinant 2a • ∙i. In this question, you are asked to write a program that finds the roots of any quadratic equation. The program requests the user to insert the three coefficients a, b, and c, respectively and outputs the values of the roots as follows: • If there are two real different roots, the program prints the root ₁ then the root 2 with a single space between them. • If there is a single real root, the program prints the root only once. • If there are two complex different roots, the program prints the root ₁ then the root x2 on a new line. )
is
e
1/0
S
1/0
• Do not add any cout statements
except for the final outputs as
shown in the sample test cases. Do
not add "Enter the cofficients",
"root1 =" or any similar prompts.
• You can include other libraries in
your code if needed.
Program Input:
The three coefficients a, b, and c of any
quadratic equation
Program Output:
The values of the roots
Sample Testcase 0:
Input:
110
Output:
-10
Sample Testcase 0:
Input:
110
Output:
-10
Input:
gr
at 1-45
rt
Sample Testcase 1:
Output:
2-11
2+1i
Sample Testcase 2:
Input:
4-41
Output:
0.5
C
E
Transcribed Image Text:is e 1/0 S 1/0 • Do not add any cout statements except for the final outputs as shown in the sample test cases. Do not add "Enter the cofficients", "root1 =" or any similar prompts. • You can include other libraries in your code if needed. Program Input: The three coefficients a, b, and c of any quadratic equation Program Output: The values of the roots Sample Testcase 0: Input: 110 Output: -10 Sample Testcase 0: Input: 110 Output: -10 Input: gr at 1-45 rt Sample Testcase 1: Output: 2-11 2+1i Sample Testcase 2: Input: 4-41 Output: 0.5 C E
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education