Exercise: Compute the roots
Question
Write a program that computes the (two) roots of a quadratic equation:
where = 1.2, = 2.3 and = −3.4.
Hint: You can hard-code values of , and and then compute and print the two solutions for , to five decimal places.
Note: We included the header file
math.hat the top. With this inclusion, you can compute the square root of a number stored in a variablexusing the syntaxsqrt(x).
Exercise: Compute the roots
Question
Write a program that computes the (two) roots of a quadratic equation:
where = 1.2, = 2.3 and = −3.4.
Hint: You can hard-code values of , and and then compute and print the two solutions for , to five decimal places.
Note: We included the header file
math.hat the top. With this inclusion, you can compute the square root of a number stored in a variablexusing the syntaxsqrt(x).