Question

Write a C++ programming code for a non-zero, discuss the roots of the quadratic equation as...

Write a C++ programming code for a non-zero, discuss the roots of the quadratic equation as follows:

a) D =0; the equation has a double solution.

     x1 = x2 = -b/2a

b) D>0; the question has two different solutions x1 and x2.

     x1= (-b-sqrt(D))/2a

     x2= (-b+sqrt(D))/2a

c) if D<0; the equation has no real solution

Homework Answers

Answer #1

#include <iostream>
#include <cmath>
using namespace std;

int main() {

double a, b, c;
double x1, x2;
double determinant;
cout << "Enter coefficients a, b and c: " <<endl;
cin >> a >> b >> c;
  
determinant = b*b - 4*a*c;
  
if (determinant == 0)
{
cout << "The equation has a double solution." << endl;
x1 = (-b ) / (2*a);
cout << "x1 = x2 =" << x1 << endl;
}

  
else if (determinant > 0) {
x1 = (-b + sqrt(determinant)) / (2*a);
x2 = (-b - sqrt(determinant)) / (2*a);
cout << " The equation has two different solutions.Roots are real and different." << endl;
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
  

else {
  
cout << "The equation has no real solution" << endl;
  
}

return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Given r_1 and r_2 are the roots of the quadratic equation ax^2 + bx + c...
Given r_1 and r_2 are the roots of the quadratic equation ax^2 + bx + c = 0, express (b^2?4ac)/2a in terms of r_1 and r_2. Re-write the quadratic formula in terms of r_1 + r_2 and and r_1 ? r_2.
USING MATLAB Write a program called QuadProg that determines the roots of a quadratic equation. Use...
USING MATLAB Write a program called QuadProg that determines the roots of a quadratic equation. Use functions to implement each action. Zip you directory of *.m files into a single file and turn this in on BBLearn under Class Activities. QuadProg write a function called getInputs to get a single input value. write a function called findDiscriminant write a function called findDenominator write a function called findRoot which will be used for both roots write a function called displayResults displayResults...
Consider the following differential equation 32x 2y '' + 3 (1 − e 2x )y =...
Consider the following differential equation 32x 2y '' + 3 (1 − e 2x )y = 0 (b) Determine the indicial equation and find its roots. (c) Without solving the problem, formally write the two linearly independent solutions near x = 0. (d) What can you say about the radius of convergence of the power series in (c)? (e) Find the first three non-zero terms of the two linearly independent solutions.
The following is the mathematical model of a linear programming problem for profit: Maximize subject to...
The following is the mathematical model of a linear programming problem for profit: Maximize subject to Z = 2X1 + 3X2 4X1+9X2 ≤ 72 10X1 + 11X2 ≤ 110 17X1 + 9X2 ≤ 153 X1 , X2 ≥ 0 The constraint lines have been graphed below along with one example profit line (dashed). The decision variable X1 is used as the X axis of the graph. Use this information for questions 19 through 23. A). Which of the following gives...
Let A be a given (3 × 3) matrix, and consider the equation Ax = c,...
Let A be a given (3 × 3) matrix, and consider the equation Ax = c, with c = [1 0 − 1 ]T . Suppose that the two vectors x1 =[ 1 2 3]T and x2 =[ 3 2 1] T are solutions to the above equation. (a) Find a vector v in N (A). (b) Using the result in part (a), find another solution to the equation Ax = c. (c) With the given information, what are the...
Python Programming 1. Write the following Python expressions in mathematical notation. a. dm = m *...
Python Programming 1. Write the following Python expressions in mathematical notation. a. dm = m * (sqrt(1 + v / c) / sqrt(1 - v / c) - 1) b. volume = pi * r * r * h c. volume = 4 * pi * r ** 3 / 3 d. z = sqrt(x * x + y * y) 2. What are the values of the following expressions? In each line, assume that s = "Hello" t =...
Choose either true or false for each statement a. There is a vector [b1 b2] so...
Choose either true or false for each statement a. There is a vector [b1 b2] so that the set of solutions to 1 0 1 0 1 0 [ x1, x2 , x3,] =[b1b2] is the z-axis.   b. The homogeneous system Ax=0 has the trivial solution if and only if the system has at least one free variable. c. If x is a nontrivial solution of Ax=0, then every entry of x is nonzero. d. The equation Ax=b is homogeneous...
Determine whether the equation is exact. If it is exact, FIND THE SOLUTION. If not write...
Determine whether the equation is exact. If it is exact, FIND THE SOLUTION. If not write NOT EXACT. A) (3x + 7) + (3y − 3)y' = 0 B) (7x2 − 2xy + 8) + (2y2 − x2 + 7)y' = 0 C) (ex sin y + 2y) − (2x − ex sin y)y' = 0 D) (y/x + 10x) + (lnx - 7) y' = 0 x>0
Use the following linear regression equation to answer the questions. x1 = 1.5 + 3.5x2 –...
Use the following linear regression equation to answer the questions. x1 = 1.5 + 3.5x2 – 8.2x3 + 2.1x4 (a) Which variable is the response variable? A. x3 B. x1     C. x2 D. x4 (b) Which variables are the explanatory variables? (Select all that apply.) A. x4 B. x1 C. x3 D. x2 (c) Which number is the constant term? List the coefficients with their corresponding explanatory variables. constant ____________ x2 coefficient_________ x3 coefficient_________ x4 coefficient_________ (d) If x2 =...
A Non-Constant Coefficient ODE: Solve the non-constant coefficient ordinary differential equation given below: ?2?2???2−34?=0, subject to...
A Non-Constant Coefficient ODE: Solve the non-constant coefficient ordinary differential equation given below: ?2?2???2−34?=0, subject to the boundary conditions (not initial conditions) ?(0)=0,?(1)=1. After solving, answer the following questions: i) Is x = 0 in the ODE a) an anomalous singular point, b) an irregular singular point, c) a regulous singularious point. d) a regular singular point? ii) If the coefficient “x2” were replaced with “x3/2” which solution series below would you use? a) ?=Σ????∞?=0, b) ?=Σ??+???+?∞?=0, s a constant,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT