Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 8 (10 points) For this problem, use the following variable declaration

ID: 3591366 • Letter: Q

Question

Question 8 (10 points) For this problem, use the following variable declaration and write two C++ assignment statements that store into variables R1 and R2 the double roots of the quadratic equation, A*X*X + B*X + C = 0. You may assume that the condition B*B 4 A*C 0 will never occur. No main() program or comments are necessary. Be sure to strike the Enter key before you click on the Save button. #include using namespace std; int main) double A,B,C,R1,R2 cin >> A >B>>C // code the assignments to R1 and R2 below

Explanation / Answer

#include<iostream>

using namespace std;

#define MINDIFF 2.25e-308  

double sqroot(double square)

{

double root=square/3, last, diff=1;

if (square <= 0) return 0;

do {

last = root;

root = (root + square / root) / 2;

diff = root - last;

} while (diff > MINDIFF || diff < -MINDIFF);

return root;

}

int main()

{

double A,B,C,R1,R2;

cin>>A>>B>>C;

R1= (-B + sqroot( (B*B) - (4*A*C) ) )/2.0;

cout<<R1<<endl;

R2= (-B - sqroot( (B*B) - (4*A*C)) )/2;

cout<<R2;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote