Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 1 . Recall that the solutions to the quadratic equation a x 2 + b x + c = 0 is given by -

Q1. Recall that the solutions to the quadratic equation
ax2+bx+c=0
is given by
-b-b2-4ac22a
and
-b+b2-4ac22a
(We will ignore the case where b2-4ac0.) Note that "square-root" is just "raise to the power of 0.5". Therefore you can write this program using the pow () function. However C++ provides a square-root function, ). In general, instead of pow (x,0.5) you should use sqrt (x).
Write a program that prompts the user for double values for double variables a, b, and c and prints the two roots according to the above two formulas. The output must be in fixed point format with 5 decimal places. Note that the computation of
b2-4ac2
appears twice, once in
-b-b2-4ac22a
and again in
-b+b2-4ac22a
Your program must compute b2-4ac2 only once to save CPU time. That implies that you should compute this value only once and store it in a variable for re-use.
TEST 1.
TEST 3.
1.C
1.4
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions