Computer Science, asked by AnirudhSaxena5089, 6 months ago

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 lobhasimali09
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