Question: This is the code I've made: #include #include #include double positiveQuad(double a, double b, double c) { double pos; pos = (-b + (sqrt(pow(b, 2)

 This is the code I've made: #include #include #include double positiveQuad(double

This is the code I've made:

#include #include #include

double positiveQuad(double a, double b, double c) { double pos; pos = (-b + (sqrt(pow(b, 2) - 4 * a * c))) / 2 * a; return pos; }

double negativeQuad(double a, double b, double c) { double neg; neg = (-b - (sqrt(pow(b, 2) - 4 * a * c))) / 2 * a; return neg; }

int main(int argc, char **argv) { double a; double b; double c; printf("Enter the values of a, b, and c: "); scanf("%lf %lf %lf ", &a, &b, &c); if (a == 0) { printf("Output: Can't divide by zero"); } else if (positiveQuad(a, b, c) == negativeQuad(a, b, c)) { printf("Output: Root is %0.2f", positiveQuad(a, b, c)); } else if ((a > 0) & (b

==============================

for some reason 2 18 0 for a b c, I would get -36 for my negative root when it's suppose to be -9. What could be wrong?

1. Roots of Quadratic Equation Write a program to compute the roots of a quadratic equation ar2 + br + c-= 0 using the well-known quadratic formula: 2a Your program will prompt the user for the values: a, b, c and output each real root However, for "invalid" input (a 0 or values that would result in complex roots), the program will instead output a message that informs the user why the inputs are invalid with a specific reason). Your output should look like the following Enter the values of a, b, and c: 2 18 0 Output: Roots are 0.00 and -9.00 Enter the values of a, b, and c: 1 -2 3 Output: Would result in a complex root

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!