a) Design and code a C function named roots that calculates the roots of a quadratic...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
a) Design and code a C function named roots that calculates the roots of a quadratic equation. Your function receives three doubles that hold the coefficients of the quadratic equation and returns through two other double parameters the real roots of the equation. The function returns the number of real roots found as the return value of the function itself. The header for your function looks something like: int roots(double a, double b, double c, double *r1, double *r2) Consider the quadratic equation: f(x) = a* x2 + b*x+c where a, b and tc are constant coefficients. This equation may have up to 2 real roots. The roots are the values of x for which a * x2 + b * x + c = 0 The roots are given by the equations x1 = (-b+sqrt( D ))/(2* a) x2 = (- b - sqrt(D))/(2* a) where D is the discriminant D = b2 - 4*a* c If D is positive-valued, there are 2 real roots. If D is zero-valued, there is one real root. If D is negative-valued, there are no real roots. If there is one real root, set x1 to its value and leave x2 unchanged. If there are no real roots, leave x1 and x2 unchanged. b) Write a main C program using dynamic memory allocation (malloc, calloc, free...) to input coefficients a, b, c as doubles and pointers to get the 2 roots of quadratic equation which uses the function roots above. a) Design and code a C function named roots that calculates the roots of a quadratic equation. Your function receives three doubles that hold the coefficients of the quadratic equation and returns through two other double parameters the real roots of the equation. The function returns the number of real roots found as the return value of the function itself. The header for your function looks something like: int roots(double a, double b, double c, double *r1, double *r2) Consider the quadratic equation: f(x) = a* x2 + b*x+c where a, b and tc are constant coefficients. This equation may have up to 2 real roots. The roots are the values of x for which a * x2 + b * x + c = 0 The roots are given by the equations x1 = (-b+sqrt( D ))/(2* a) x2 = (- b - sqrt(D))/(2* a) where D is the discriminant D = b2 - 4*a* c If D is positive-valued, there are 2 real roots. If D is zero-valued, there is one real root. If D is negative-valued, there are no real roots. If there is one real root, set x1 to its value and leave x2 unchanged. If there are no real roots, leave x1 and x2 unchanged. b) Write a main C program using dynamic memory allocation (malloc, calloc, free...) to input coefficients a, b, c as doubles and pointers to get the 2 roots of quadratic equation which uses the function roots above.
Expert Answer:
Related Book For
Introduction to Operations and Supply Chain Management
ISBN: 978-0132747325
3rd edition
Authors: Cecil B. Bozarth, Robert B. Handfield
Posted Date:
Students also viewed these accounting questions
-
The roots of the quadratic equation ax 2 + bx + c = 0 are given by a. Develop a pseudocode description of a program to compute both roots given the values of a, b, and c. Be sure to identify the real...
-
The graph of a quadratic equation in x and y can, in certain cases, be a point, a line, or a pair of lines. These are called degenerate conics. It is also possible that the equation is not satisfied...
-
The solutions of a quadratic equation are (a) Prove that the sum of the solutions is s = - b/a. (b) Prove that the product of the solutions is P = c/a? -b + /B 4ac r%3D 2a
-
Dylan Flaherty, marketing clerk for TipTop Marketing Agency, recorded the following information for last year: He would like to be able to estimate customer service costs using the number of...
-
The actuary for the pension plan of Regina Company calculated the following net gains and losses. Incurred during the Year (Gain) or Loss 2014 ........$ (660,000) 2015 ........ 250,000 2016 ...........
-
In Exercises 3 through 36, find the indicated integral and check your answer by differentiation. Vx feve X dx
-
Florida Tile produces ceramic tiles using two sequential production departments: Tile-Forming and Tile-Finishing. The following information was found for Florida Tiles first production process, the...
-
Merando Corporation was formed on January 1, 2014. At December 31, 2014, Bill Jensen, the president and sole stockholder, decided to prepare a balance sheet, which appeared as follows. Bill willingly...
-
1. 49 The value of n(n+n+1) is equal to (10a) [10a-3. The value of (a + ) is n=1 48 47 46 2 1 2. If + + + + + = (2)(3) (3)(4) (4)(5) (48)(49) (49)+(50) k is equal to 3. +++++ Then 4. 5. In a...
-
1 What are the main components of personal financial planning? Solve What is the purpose of a financial plan? Solve Identify some common actions taken to achieve financial goals. How does a job...
-
Inorganic phosphate inhibits the phosphatase activity, less pNP are formed when high conc. of inorganic phosphate are added. How phosphate inhibits the production of pNP and which stages of...
-
Robert is a 16-year-old who woke up with a left-sided facial droop. He has no paralysis on his left arm or leg and is otherwise well. What does the evidence suggest about the etiology of his...
-
What is the coupon rate of a eight-year, $10,000 bond with semiannual coupons and a price of $8,222.36, if it has a yield to maturity of 7.4%?
-
a) A researcher investigating the factors determining wages estimates models (1) and (2) below using information on a cross-sectional sample of data on wages for 525 US workers recorded in 2005. Note...
-
A stock is expected to pay its first annual dividend in 5 years. The dividend is expected to stay constant at $1.3 per year for 18 years and then grow at 5% annually forever. The required rate of...
-
A call option on a stock that does not pay dividends has the following parameter values (in the usual notation): S=240, K=250, T=0.5, r=0.06, a=0.2 The graphs below show the theoretical price of this...
-
A machine that cost $900,000 was purchased on January 1, 2025. Its estimated salvage value is $90,000 and its expected useful life is 4 years. Instructions (1) Calculate the depreciation expense by...
-
Describe basic managerial approaches to implementing controls and how these are implemented.
-
The following gure shows an expanded version of the Excel spreadsheet described in Using Excel in Capacity Management (page 168). In addition to the break-even and indifference points, the expanded...
-
Use the P&G example at the beginning of the chapter to explain the benets to the customer of adopting a business processes perspective. Why might a traditional functional perspective have blinded P&G...
-
ABS sells construction materials to commercial and home builders. One of ABS's key processes is the order fulfillment process shown below and described as follows: All orders are assessed on...
-
Perhaps the most famous case illustrating the enormous cost of winning back lost customers is that of the Tylenol Murders. Seven people in the Chicago area died suddenly after taking Tylenol...
-
Give a brief rationale for empowerment.
-
Describe the concept of MBWA.
Study smarter with the SolutionInn App