Write a c++ program to evaluate the following expression X1= (-b+[√b^2-4ac]) /2a and 2nd is X2= [-b+(-√b^2-4ac)]\2a with output
Answers
Answered by
3
Explanation:
#include <iostream.h>
#include<math.h>
void main ( )
{
int a, b, c,d;
float x1,x2;
cout<<" enter the coefficients of the equation as a, b, c";
cin>>a>>b>>c;
d = (b*b) - (4*a*c);
x1 = (-b + sqrt(d)) / (2*a);
x2 = x1 = (-b - sqrt(d)) / (2*a);
cout<<"root 1 = "<<x1;
cout<<"root 2 = "<<x2;
}
hope this helps.
Similar questions
Social Sciences,
3 months ago
History,
3 months ago
Political Science,
3 months ago
Hindi,
6 months ago
English,
10 months ago