(a) Write a function for computing the roots using the following function header: int compute_roots (double...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Write a function for computing the roots using the following function header: int compute_roots (double a, double b, double c, doubles x1, double& x2) The arguments a, b, c are the coefficients of the quadratic equation, and x1 and x2 are possible computed roots of the equation (depending on the return value). The return value of this function could be one of the numbers: 0 == no roots 1 == one root 2 == two real roots 3 == infinite number of roots 4 == no real roots You should save the return value in a variable, say, nroots and use it later in a switch statement switch (nroots). Do not include any input or output statement inside compute_roots(). All input/output statements should be in main () only. (b) Test your function in main () for five different quadratic equations. Use the included flow chart when writing the function. Flowchart for ax²+bx+c=0 Input a, b, c a=0 No b²-4ac A20 No Yes Yes X2--6/2a+1√ A/28 x2--8/28-13/2a (degenerative case) Yes Yes b=0 No x = -c/b Linear equation i 4-0 Yes c=0 (Compute Discriminant) No Solutions XI-(-8-/5/28 22-(-8-/5/28 No or No Two Complex Real Roots Roots x=-b/2a Infinite # of roots Two Real Roots Double Root (a) Write a function for computing the roots using the following function header: int compute_roots (double a, double b, double c, doubles x1, double& x2) The arguments a, b, c are the coefficients of the quadratic equation, and x1 and x2 are possible computed roots of the equation (depending on the return value). The return value of this function could be one of the numbers: 0 == no roots 1 == one root 2 == two real roots 3 == infinite number of roots 4 == no real roots You should save the return value in a variable, say, nroots and use it later in a switch statement switch (nroots). Do not include any input or output statement inside compute_roots(). All input/output statements should be in main () only. (b) Test your function in main () for five different quadratic equations. Use the included flow chart when writing the function. Flowchart for ax²+bx+c=0 Input a, b, c a=0 No b²-4ac A20 No Yes Yes X2--6/2a+1√ A/28 x2--8/28-13/2a (degenerative case) Yes Yes b=0 No x = -c/b Linear equation i 4-0 Yes c=0 (Compute Discriminant) No Solutions XI-(-8-/5/28 22-(-8-/5/28 No or No Two Complex Real Roots Roots x=-b/2a Infinite # of roots Two Real Roots Double Root
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Describe a recursive function for computing the nth Harmonic number, n H = , 1/i. Hn
-
Describe a recursive function for computing the nth Harmonic number, Hn = ni=1 1/i.
-
International mutual funds do not include any domestic assets whereas global mutual funds include both foreign and domestic assets. How might this difference affect their correlation with US equity...
-
Below are three independent and unrelated errors. a. On December 31, 2020, Wolfe-Bache Corporation failed to accrue salaries expense of $1,800. In January 2021, when it paid employees for the...
-
Central Innovations Company sponsors a defined-benefit pension plan for its 175 employees. The companys actuary provided the following information about the plan. The average remaining service life...
-
In Exercises 15 through 44, evaluate the given definite integral using the fundamental theorem of calculus. In 2 (e - e) dt
-
This problem extends the Summary Problem 1 to a second department. During May, Florida Tile Industries reports the following in its Tile-Finishing Department: Requirements: 1. Complete the five-step...
-
Matilda Crone owns and operates a public relations firm called Dance Fever. The following amounts summarize her business on August 31, 2012: During September 2012, the business completed the...
-
6. 7. 8. If one of the diameters of the circle x + y-2x-6y+6=0 is a chord of another circle 'C', whose centre is at (2, 1), then its radius is Let Bi (i = 1, 2, 3) be three independent events in a...
-
The trial balance of Jeremina plc as at 31 March 20X2 is as follows: Notes: (i) Stock of finished goods on 31 March 20X2 163,000. (ii) Motor expenses and depreciation on motors to be apportioned:...
-
Choose two (2) set of financial statements of two companies of UAE for the same latest financial year from similar industries, which are publicly available (online), and: 1. Recognize and describe...
-
You are given that the fair price to pay at time for a derivative paying X at time T is V = e)E[X|F], where Q is the risk-neutral probability measure and F, is the filtration with respect to the...
-
Jacklyn is awarded $4000 on August 16th, 2023 on a dept owned to her by Mr. Kale. Mr. kale paid the debt on December 14, 2023, with an interest rate of 5% as prescribed by the court. how The 5%...
-
Parkinson Plc is considering a major investment project in a new product, the Legend. Market research indicates that the demand for the Legend at a unit selling price of 12.00 and advertising costs...
-
You are making and designing investment portfolios for two unrelated investors.Each has $2,000,000 to invest and you can offer them shares in one or more of the four real estate investments shown in...
-
Use the graph below depicting a profit-maximizing, perfectly competitive firm to answer questions 1 through 5. 1. 2. 3. 4. 5. a. Price $22 $20 $12 $10 Marginal revenue is equal to $10 b. a. b. $4 C....
-
The following information was obtained from Cyber Corporation's annual report. Common stock: shares outstanding Balance on January 1 April 1-issued in conversion of preferred stock July 1-sold for...
-
Suppose that the electrical potential at the point (x, y, z) is E(x, y, z) = x + y - 2z. What is the direction of the acceleration at the point (1,3,2)?
-
(a) state the domain of the function, (b) identify all intercepts, (c) find any vertical or slant asymptotes, and (d) plot additional solution points as needed to sketch the graph of the rational...
-
You are starting a small business. You have 9 investors who are willing to share equally in the venture. When you add 3 more investors, each person's share decreases by $2500. What is the total...
-
The Mach number M of a supersonic airplane is the ratio of its speed to the speed of sound. When an airplane travels faster than the speed of sound, the sound waves form a cone behind the airplane....
-
A professional baseball team set its sights on winning the World Series. The team owner wanted to win big and win fast. Consequently, the team sank all of its resources into trading for the best...
-
Immediately following World War II, the quality of products produced by Japanese companies was not good enough to compete in the international marketplace. The only advantage Japanese companies had...
-
Two quality managers meet for lunch every Friday to discuss common problems, compare notes, and make suggestions to each other. Today their discussion has turned into a debate. The topic is the...
Study smarter with the SolutionInn App