EXelelse 2_bugs3.c cied3 /* Solution of a*x*x + b*x + c = 0 */ #include #include int main (void) { do
Posted: Fri May 20, 2022 5:24 pm
Output
EXelelse 2_bugs3.c cied3 /* Solution of a*x*x + b*x + c = 0 */ #include <stdio.h> #include <math.h> int main (void) { double a, b, c, rooti, root2; printf("Input the coefficient a=> "); scanf("%1f", &a); printf ("Input the coefficient b=> "); scanf("%1f", &b); printf("Input the coefficient c=> "); scanf("%1f", &C); /*Compute the roots. */ root1=(-b+ sqrt (b*b-4*a*c))/(2*a); root2 = (-b- sqrt (b*b-4*a*c))/(2*a) ; = printf("The first root is %8.3f\n", root1); printf("The second root is %8.3f\n", root2); return 0; }
Suppose we input: a = 2, b = 6, C = 1 = There are 2 space characters + The remaining 6 characters are '-', '0', ', '1', '7' and '7' II Thus, there are -0.177 8 characters in -2.823 total Screen Output: The first root is The second root is
Input the coefficient a=> 2 Input the coefficient b=> 6 Input the coefficient c=> 1 The first root is -0.506 The second root is -0.506 execution time: 7.989 S Process returned o (Oxo) Press any key to continue.
EXelelse 2_bugs3.c cied3 /* Solution of a*x*x + b*x + c = 0 */ #include <stdio.h> #include <math.h> int main (void) { double a, b, c, rooti, root2; printf("Input the coefficient a=> "); scanf("%1f", &a); printf ("Input the coefficient b=> "); scanf("%1f", &b); printf("Input the coefficient c=> "); scanf("%1f", &C); /*Compute the roots. */ root1=(-b+ sqrt (b*b-4*a*c))/(2*a); root2 = (-b- sqrt (b*b-4*a*c))/(2*a) ; = printf("The first root is %8.3f\n", root1); printf("The second root is %8.3f\n", root2); return 0; }
Suppose we input: a = 2, b = 6, C = 1 = There are 2 space characters + The remaining 6 characters are '-', '0', ', '1', '7' and '7' II Thus, there are -0.177 8 characters in -2.823 total Screen Output: The first root is The second root is
Input the coefficient a=> 2 Input the coefficient b=> 6 Input the coefficient c=> 1 The first root is -0.506 The second root is -0.506 execution time: 7.989 S Process returned o (Oxo) Press any key to continue.