2Answers

# When the c language is rooted, why is c a negative debug flashback?

Asked by: Marie Green 207 views IT

{/* Find the root of the equation ax*x+bx+c=0, a, b, c are input by the keyboard, set b*b-4ac>0.

*/

float a, b, c, p, q, x1, x2;

printf("enter the values of a,b,c and calculate ax*x+bx+c= The root of the 0 equation, pay attention to guarantee b*b-4ac>0\n");

scanf_s("%f,%f,%f", &a, &b, &c);

p = -1.0*b / (2 * a);

q = sqrt(b*b - 4 * a*c) / (2.0*a);

x1 = p + q;

x2 = p - q;

printf("p=%f\n,q=%f\n", p,q );

printf("root x1=%f\nrootx2=%f\n", x1,x2);

getchar();

getchar();

//A doubt, why does the debugging flash back when c is negative?

}

+4

VotesIt should not be because the value of c is negative, but because the value of

(b*b – 4 * a*c) is negative, it will flash back

In C language, sqrt can’t ask for the negative number of

You have to make a judgment (of course, a can’t be 0, otherwise it will flash back)

Brenda- August 3, 2019 |

+6

Votes1. printf(“\n press any key to continue…”); getchar(); return 0; 2. The header file contains sysytem(“PAUSE”) of stdio.h; return 0;

Michelle Green- August 4, 2019 |