# help in Formula roots

#include
using namespace std;
int main(int argc, char** argv) {
int a=5;
int b=3;
int c=2;
cout== -b+sqrt bb-4a*c/2a==0;
return 0;
}

thats no worked me i try 2 hours and dont know what a problem
that in Formula roots

Captain-B_:
cout== -b+sqrt bb-4a*c/2a==0;

== is a comparison of two things. = is the assignment operator. And you can't have two of them in one statement like that. Well, you can technically but it doesn't do what you think it does.

You really need to look at some basic tutorials on C++ or you are going to drive yourself mad trying to "guess" the syntax.

Write like this:

``````int root = (-b + (sqrt(b*b - (4*a*c)))) / (2*a) ;
``````

You can't write like you would for a person on paper. You have to write so a computer can read.

so maybe you can show me what need write pls?

Delta_G:
== is a comparison of two things. = is the assignment operator. And you can't have two of them in one statement like that. Well, you can technically but it doesn't do what you think it does.

You really need to look at some basic tutorials on C++ or you are going to drive yourself mad trying to "guess" the syntax.

Write like this:

``````int root = (-b + (sqrt(b*b - (4*a*c)))) / (2*a) ;
``````

You can't write like you would for a person on paper. You have to write so a computer can read.

hopefully all of the terms are Floats, very few roots to a quadratic are integers. what does sqrt() return for negative values?

Chuck.

thats not work

#include
using namespace std;
int main(){
int a=2;
int b=3;
int c=4;
int root = (-b + (sqrt(bb - (4ac))) / (2a) ;
return=0
}

Try evaluating the expression using integer arithmetic and then get back to us.

Maybe even try some valid syntax

#include
using namespace std;
int main(){
int a=1;
int b=3;
int c=2;
int root << (-b + (sqrt(bb -4ac)) / (2a)= ;
return=0
}

now it integer and that no work

C:\Users\DANIF\Downloads\úøâéì 2.cpp [Error] expected primary-expression before '=' token
thats a problem what it mean?

Have a closer look at "return"

Also look closer at "int root..."

i did not understand you you can maybe write me this line pls?

I don’t understand you either.
Maybe you could be more specific.

i ask you if you write me this code and see if its work and send me

OK, how much do you pay me for this service?

Before you answer that, have another read of reply #2

Yeah I guess it should have been a float huh?

``````float root = (-b + (sqrt(b*b - (4*a*c)))) / (2*a) ;
``````

OP, you had it almost right in reply #5. At the end of that program the root variable would have held a number you calculated. But then you just return 0 and don’t do anything with the value you just created. Maybe you should print it out on the monitor or something.

Either way, you’ve got to go do some reading. Right now you are trying to guess at the syntax and that is causing nothing but frustration for you and for us. The people here are volunteers who have selflessly given their time to try to help you. Please be considerate enough not to waste their time.

Why do you think it is not working?
Did you get a value that you suspect is not correct? What did you expect? What did you get?

side question: What Arduino board are you using?