1

The roots of the quadratic equation ax2 + bx + c = 0, a following formula:...

Question

The roots of the quadratic equation ax2 + bx + c = 0, a following formula:...

The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two real roots. If4aco, the equation has two t term) and outputs the type of roots of the equation. Further- more, if b0, 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. tion pow is used.)
The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two real roots. If4aco, the equation has two t term) and outputs the type of roots of the equation. Further- more, if b0, 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. tion pow is used.)

Answers

#include <iostream>
#include <cmath>//to use sqrt function
using namespace std;

int main()
{

float a, b, c, x1, x2, D, Real_Part, Imaginary_Part;
//declaration of variables
cout << "Enter coefficients a, b and c: ";

//cin is used to read the values of coefficients of the quardratic equation   
cin >> a >> b >> c;
// calculating Discriminant
D = b*b - 4*a*c;
  
  
if (D > 0)
// means roots exist and they are different
{
x1 = (-b + sqrt(D)) / (2*a);
x2 = (-b - sqrt(D)) / (2*a);
cout << "Roots are real and different." << endl;
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
  
//means roots exit and they are same   
else if (D == 0)
{
cout << "Roots are real and same." << endl;
x1 = (-b + sqrt(D)) / (2*a);
cout << "x1 = x2 =" << x1 << endl;
}
//if Discriminant is less than zero then roots will be Imaginary
else
{
Real_Part = -b/(2*a);
//to calculate imaginary part for each root
Imaginary_Part =sqrt(-D)/(2*a);
  
cout << "Roots are complex and different." << endl;
cout << "x1 = " << Real_Part << "+" << Imaginary_Part << "i" << endl;
cout << "x2 = " << Real_Part << "-" << Imaginary_Part << "i" << endl;
}

return 0;
}


Similar Solved Questions

1 answers
R 37. Singular radial field Consider the radial field (x, y, z) F (x2 + y2...
r 37. Singular radial field Consider the radial field (x, y, z) F (x2 + y2 + z2)1/2" a. Evaluate a surface integral to show that SsFonds = 4ta?, where S is the surface of a sphere of radius a centered at the origin. b. Note that the first partial derivatives of the components of F are undefined ...
1 answers
1. In the past, self injury was often called a suicide gesture, it is now seen...
1. In the past, self injury was often called a suicide gesture, it is now seen in a different light. How do you explain self injury and how would you assess it and what would be your plan for treatment?...
1 answers
If you began with 192 mg of trans-1,2-dibenzoylethylene and recovered 82 mg of cis-1,2-dibenzoylethylene, what is...
If you began with 192 mg of trans-1,2-dibenzoylethylene and recovered 82 mg of cis-1,2-dibenzoylethylene, what is your percent yield? Round your answer to the nearest percent. Your Answer...
1 answers
Required information [The following information applies to the questions displayed below.] Vail Resorts, Inc., owns and...
Required information [The following information applies to the questions displayed below.] Vail Resorts, Inc., owns and operates 11 premier year-round ski resort properties (located in the Colorado Rocky Mountains, the Lake Tahoe area, the upper midwest, Vermont, and Australia). The company also own...
1 answers
Fincher Farms uses process costing to account for the production of canned vegetables. Direct materials are...
Fincher Farms uses process costing to account for the production of canned vegetables. Direct materials are added at the beginning of the process and conversion costs are incurred uniformly throughout the process. Beginning work in process is 30 percent complete; ending work in process is 40 percent...
1 answers
Me Unuwing table shows the average returns for some of the largest mutual funds commonly found...
Me Unuwing table shows the average returns for some of the largest mutual funds commonly found in retirement plans. (Assume end-of-month deposits and withdrawals and monthly compounding, and assume that the quoted rate of return continues indefinitely.) Mutual Fund Fidelity Growth Company Vanguard 5...
1 answers
What volume of a solution of potassium permanganate ( 81 mg / mL) is required for...
What volume of a solution of potassium permanganate ( 81 mg / mL) is required for the preparation of 8.3 L of a solution containing the substance at a concentration of 1 in 4,000?(no decimal place)...
1 answers
The figure shows three long, parallel, current-carrying wires perpendicular to the page. In the picture, the...
The figure shows three long, parallel, current-carrying wires perpendicular to the page. In the picture, the current directions are indicated for I1 and I3. The three currents have equal magnitudes. The direction of the current I2 is INTO the page. Determine the direction of the net force acting on ...
1 answers
St Name: First Name CWID: Problem 2 (30 pts): In the frame shown, all members are...
St Name: First Name CWID: Problem 2 (30 pts): In the frame shown, all members are connected by pins at all points. P-300 N and w 800 N/m and M 400 Nm (a) Identify any two force members, solve for the magnitude of the force and identify if they are in tension or compression. (b) Solve for all reactio...
1 answers
10. The time,t,in seconds varies directly with the square root of the distance, d, in feet...
10. The time,t,in seconds varies directly with the square root of the distance, d, in feet that a dropped ball has fallen. It takes 2 seconds for a ball to fall 64 feet. a. Find a formula to model this situation. b. How long would it take for the ball to fall 100 feet?...
1 answers
What are the other nations called besides US medical group and how they are similar and...
what are the other nations called besides US medical group and how they are similar and different ? 2. How does the American College of Medical Practice Executives (ACMPE) define competency for group practice administrators? 3. List 9 functions that are the responsibility of non physician lead...
1 answers
Order: penicillin G procaine 700,000 units IM 12h. The label on the vial reads 500,000 units...
Order: penicillin G procaine 700,000 units IM 12h. The label on the vial reads 500,000 units per milliliter. How many milliliters will you administer per dose? O A. 1.4 ml OB. 0.5 mL OC. 3 mL OD. 2 mL...
1 answers
1. Order: Amikin 0.15 Gm, IM, three times a day. Available: MOC 00 15-3015-20 Amikin AMACIN...
1. Order: Amikin 0.15 Gm, IM, three times a day. Available: MOC 00 15-3015-20 Amikin AMACIN SULFATE MUJECTION Fortal. Uw EQUIVALENT TO 100 no EZIVOLYYTYI 10M 3015200RL-06 an 5 with M,50 View 0.13sodium bisulfite added aan alondant, utlernd win 0.5 sodium citrate, dusted to pH U.S. 3.71.280 14.024,34...
1 answers
Vibrations that move through the ground carrying the energy released during an earthquake is called what?
Vibrations that move through the ground carrying the energy released during an earthquake is called what?...
1 answers
Hello Expert, Can I get help with this home work. Thank you                                 &nb
Hello Expert, Can I get help with this home work. Thank you                                         ...
1 answers
Financial Reporting Problem: Apple Inc. CT11.1 The stockholders' equity section for Apple Inc. is shown in...
Financial Reporting Problem: Apple Inc. CT11.1 The stockholders' equity section for Apple Inc. is shown in Appendix A. The complete annual report, including the notes to the financial statements, is available at the company's website. Instructions a. What is the par or stated value per share...
1 answers
Can you answer questions 7, 10, 11 and 13. thanks! Question Completion Status: QUESTION7 Refer to the following figure showing the reaction functions of oligopoly firms A and B OR, BR Bs Advert...
can you answer questions 7, 10, 11 and 13. thanks! Question Completion Status: QUESTION7 Refer to the following figure showing the reaction functions of oligopoly firms A and B OR, BR Bs Advertising In Nash equilibrium, both firms are maximizing their own profits given the level of advertising...
1 answers
TCT Ser (S TTT Phe (F) TTC TTA Leu (L) TAT TY TAC TAA Ter TAG...
TCT Ser (S TTT Phe (F) TTC TTA Leu (L) TAT TY TAC TAA Ter TAG Ter T UT Cys (C) TGC TGA Ter TGG TIP (W) TOG CTT Leu (1) CCT Pro) COT Ang cze CAC. CTA CTG CATH CAA Gin (0) CAG" OG COG OGG - AGT Ser ATT Ile (1) ATC ATA" ATG Met (4) ACT Th (1) ACC ACG AAT As ) AAC- AAA Lys) AGE АС...
1 answers
Stock price of $42, earnings of $2.12 per share during the last twelve months, forecasted earnings...
Stock price of $42, earnings of $2.12 per share during the last twelve months, forecasted earnings of $2.84 over the following year, and average earnings growth forecast of 12.5% per year for the next five years. What is this stock's PEG, rounded to one decimal place?...
1 answers
22% of all people are blonde, 40% brown hair, 5% red hair, 20% black and the...
22% of all people are blonde, 40% brown hair, 5% red hair, 20% black and the rest are other color. You select 10 people at one time. What is the probability you get 2 blonde, 3 brown, 2 red and 3 black hair?...

-- 0.037728--