Quad equation using fuctions problem
Code:
#include <iostream>
using namespace std;
void quadraticequation(float a, float b, float c);
int main()
{
int a,b,c;
cout <<"a"<< endl;
cin>>a;
cout<<"b"<<endl;
cin>>b;
cout<<"c"<<endl;
cin>>c;
quadraticequation(a,b,c);
}
void quadraticequation(float a, float b, float c)
{
if (((b*b)-4*a*c)<0)
{
cout<<"No real solution"<<endl;
}
else if (((b*b)-4*a*c)=0 )
{
cout<<"Answer is"<<-b/2*a;
}
else if (((b*b)-4*a*c)>0)
{
cout<<"X1 ="<< -b+sqrt((b*b)-4*a*c)/2*a;
cout<<"X2 ="<< -b-sqrt((b*b)-4*a*c)/2*a;
}
}
In the above code I'm to write out a function that solves a quadratic equation. I have one error that comes up but I dont know how to stop it because it seems okay to me(the beginner :rolleyes: ). Does anyone know where I went wrong??