Question: hey so the first picture is the assignment and the second picture it show an error everytime i try to run it it gave me

 hey so the first picture is the assignment and the second

picture it show an error everytime i try to run it it

hey so the first picture is the assignment and the second picture it show an error everytime i try to run it it gave me a -1.$ all the time and i dont why. i have the my code maybe you can help me find an error in my code please and thank you.

gave me a -1.$ all the time and i dont why. i

#include #include

int main() { double a, b, c; // coefficients of quadratic formula double descriminant; // for calculation of descriminant double root1; // will calculate positive root inside main function double root2; // will calculate negative root inside main function double realPart; // will calculate the real part of the quadratic equation double imaginaryPart; // will calculate the imaginary part of the eqaution double posroot (a, b ,c ,descriminant); // prototype function to calculate the positive roots double negroot (a, b ,c ,descriminant); // prototype function to calculate the negative roots printf("Enter coefficient of a : "); scanf("%lf",&a); printf("Enter coefficients of b : "); scanf("%lf",&b); printf("Enter coefficients of c : "); scanf("%lf",&c); if(a != 0) { descriminant = b*b-4*a*c; // condition for real and different roots if (descriminant > 0) { // sqrt() function returns square root root1 = posroot (a, b ,c ,descriminant); root2 = negroot (a, b ,c ,descriminant); printf("root1 = %.1lf and root2 = %.1lf",root1 , root2); } //condition for real and equal roots else if (descriminant == 0) { root1 = root2 = -b/(2*a); printf("root1 = root2 = %.2lf;", root1); } // if roots are not real else { realPart = -b/(2*a); imaginaryPart = sqrt(-descriminant)/(2*a); printf("root1 = %.1lf+%.1lfi and root2 = %.1f-%.1fi", realPart, imaginaryPart, realPart, imaginaryPart); } } else { printf("Division by Zero"); } return 0; } double posroot (a, b ,c ,descriminant) { double root = (-b +sqrt(descriminant))/(2*a); return root; } double negroot (a, b ,c ,descriminant) { double root = (-b -sqrt(descriminant))/(2*a); return root; }

Write a program to read the coefficients a, b, and c of a quadratic equation and print its roots, the values of x such that ax bx c 0. The roots are given by: bt vb- 4ac The discriminant is b-4ac. Make all of the variables of type double. Create two functions, besides the main function. One function should return the positive root and the 2a other the negative root of the quadratic formula. Place the two function prototypes locally inside of the main) function, rather than globally. Use local variables, rather than global variables Format your output to one decimal place ue 2. x-15x 3. x-16 4. 6X+3 1.0 1.0 6.0 1.0 -15.0 0.0 1.0 0.0 16.0 0.0 6.0 3.0 3.0 3.0 6.0 3x2 3x-6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!