Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

I was asked to write a program that finds the solutions, if any, to a given quadratic equation. My code is below. I have two issues: First When i input for example, a=3, b=4, c=5 the result prints" The roots are -nan and -nan" Secondly, I am to ensure that division by 0 is not permitted and the discriminant b^2-4ac cannot be negative. I am having a hard time with this bit. Could you help me solve this part?

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

HERE IS MY CODE: #include #include using namespace std; int main(){ /* Here I have initialized some variables a,b and c that you would see in a standard quadratic equation. positive_root and negative_root are the roots you get when using the quadratic formula to solve a quadratic equation given the values of a,b and c */ double a, b, c, positive_root, negative_root; cout<<" enter value of a,b and c : "<>a>>b>>c; // using the functions sqrt() and pow(), we positive_root= (-b + sqrt(( pow(b,2)- 4*a*c)))/ 2*a ; negative_root= (-b - sqrt(( pow(b,2)- 4*a*c)))/ 2*a ; cout << " The roots are:"<

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question