Hello,
I try to solve an equation. I wtrote this code that compiles with no problem but when I run it it gives me no result. Can anyone help me?
Thanks
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double a,b,c;
cout<<"Introduce a,b,c\n";
cin>>a>>b>>c;
if(a=0)
if(b=0)
if(c=0)
{
cout<<"The ecuation has an infinity of soultion";
}
if(a=0)
if(b=0)
if(c !=0)
{
cout<<"The ecuation has no solution";
}
if(a=0)
if(b!=0)
if(c!=0)
{
double x;
x=-c/b;
cout<<" The value of x is: "<<x<<endl;
}
if(a!=0)
{
double delta;
delta = (b*b) -4*(a*c);
if(delta>0)
{
double x_1, x_2;
x_1=(-b+sqrt(delta))/2*a;
x_2=(-b-sqrt(delta))/2*a;
cout<<" The value of x is = " <<x_1 <<" or" << " "<<x_2;
}
if(delta<0)
{
double x_1, x_2;
x_1=(-b+sqrt(-delta))/2*a;
x_2=(-b-sqrt(-delta))/2*a;
cout<<" The value of x is = " <<x_1 <<" or" << " "<<x_2;
}
}
system("pause");
return 0;
}