The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the user to input the value of: a (the coefficient of x²) b (the coefficient of x) c (the constant term) The program then outputs the type of roots of the equation. Furthermore, if b² - 4ac ≥ 0, the program should output the roots of the quadratic equation. (Hint: Use the function pow from the header file cmath to calculate the square root. Chapter 3 explains how the function pow is used.)
The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula:
In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots.
Instructions
Write a program that prompts the user to input the value of:
- a (the coefficient of x²)
- b (the coefficient of x)
- c (the constant term)
The program then outputs the type of roots of the equation.
Furthermore, if b² - 4ac ≥ 0, the program should output the roots of the quadratic equation.
(Hint: Use the function pow from the header file cmath to calculate the square root. Chapter 3 explains how the function pow is used.)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images