imaginary number in c++
could someone help me on what to input on C++ so that i can get the imaginary roots of a quadratic equation....
I really don't know what to do...ðŸ˜
help me please..😕😕ðŸ˜
thank you!!
I really don't know what to do...ðŸ˜
help me please..😕😕ðŸ˜
thank you!!
Replies
-
vinci
try this equation. let me know if it doesnt work still -
silverscorpionUse a variable to indicate whether the delta (B[sup]2[/sup]-4AC) is positive or negative.
Instead of
pro = sqrt((b*b)-(4*a*c));
here, use
pro = sqrt(abs(B*B)-(4*A*C))
And then, if delta is positive, use it as is. If delta is negative, just print an 'i' or 'j' along with the result, to indicate that the root is imaginary... -
maria flor
it doesn't workvinci
try this equation. let me know if it doesnt work still -
maria flor
i just tried it but when i try to input an equation with imaginary roots.. it doesn't give me an answer...silverscorpionUse a variable to indicate whether the delta (B[sup]2[/sup]-4AC) is positive or negative.
Instead of
pro = sqrt((b*b)-(4*a*c));
here, use
pro = sqrt(abs(B*B)-(4*A*C))
And then, if delta is positive, use it as is. If delta is negative, just print an 'i' or 'j' along with the result, to indicate that the root is imaginary... -
maria flor
thanks for that but when i try to input an equation with imaginary roots.. it still doesn't give an answer...silverscorpionUse a variable to indicate whether the delta (B[sup]2[/sup]-4AC) is positive or negative.
Instead of
pro = sqrt((b*b)-(4*a*c));
here, use
pro = sqrt(abs(B*B)-(4*A*C))
And then, if delta is positive, use it as is. If delta is negative, just print an 'i' or 'j' along with the result, to indicate that the root is imaginary... -
silverscorpionAfter you have calculated delta, (variable "pro" in your program), calculate the individual roots in the following way..
pro = sqrt(abs(B*B-4*A*C)) if ((B*B-4*A*C) >= 0) { x1 = (-B+pro)/2*A x2 = (-B-pro)/2*A cout << "The first root is " << x1 << endl cout << "The second root is " << x2 << endl } else { real = -B/2*A imag = pro/2*A cout << "The first root is "<
Try using this.. -
vinciyou need value of of a,b,c ?i found that equation i posted here gives complex roots .
-
maria flor
it still don't work... when i try to run it and input values with imaginary roots it suddenly return...silverscorpionAfter you have calculated delta, (variable "pro" in your program), calculate the individual roots in the following way..
pro = sqrt(abs(B*B-4*A*C)) if ((B*B-4*A*C) >= 0) { x1 = (-B+pro)/2*A x2 = (-B-pro)/2*A cout << "The first root is " << x1 << endl cout << "The second root is " << x2 << endl } else { real = -B/2*A imag = pro/2*A cout << "The first root is "<
Try using this.. -
silverscorpionWhat is the input you are giving and what is the output?
Give the full dump.. -
maria florhere: when i input those numbers...it returns without giving any roots...
You are reading an archived discussion.
Related Posts
technical paper writing is a new concept for me... plz tell me abt it or giv me sum directions .... how can a present a paper at clg level...
What is SAP and How to learn it..! Can I learn it online ?
Guys, Indian Hockey (Women) have put a brilliant performance kudos to them for they have earned it.
Its a proud moment for Indians.
Wishing them good luck for comming matches......
Hello guys
If you know any web designer in Personal then Please ask him to contact me
I am in great need of him
Designer will be paid on the...
Hello guys,
I am working on modeling a tire in NX I-Deas. I am stuck on the part where I have to extrude on tire curved surface. I don't know...