1. ## 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;

}

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 )
{
}

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 ). Does anyone know where I went wrong??

2. Try to always tell us what the errors are when you get them. It seems to me the error comes from the fact that you have mistaken '==' for '='. It's in your first 'else if' statement.

3. Well, mathematically you should have
Code:
```	  cout<<"X1 ="<< (-b+sqrt((b*b)-4*a*c))/(2*a);
cout<<"X2 ="<< (-b-sqrt((b*b)-4*a*c))/(2*a);```
You could also save some typing by defining a variable for b*b-4*a*c.

Edit: And also
Code:
`		cout<<"Answer is"<<-b/(2*a);`

4. Code:
```#include <math.h>
#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;

}

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 )
{
}

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;
}

}```

5. there are two more places with /2*a that should be fixed

6. Thanks guys, It works now. I really appreciate the help, I have an exam in this Wednesday and up till today I was clueless, still am but I think I know the basics.