Problem Analysis:
The problem is to read the values of coefficient a,b,c of quadratic equation ax²+bx+c=0 and to find the equation of the roots.
i.e. r1 =(-b + sqrt (d) /(2*a); d=(b*b)-(4*a*c);
r2=(-b- sqrt (d)/(2*a);
Input variables Processing variables Output variables Necessary header files
a(int) r1=(-b+sqrt(d)/(2*a); r1(float) stdio.h
b(int) r2=(-b-sqrt(d)/(2*a); r2(float) conio.h
c(int) d=(b*b) – (4*a*c); math.h
d(int)
r1(float)
r2(float)
Algorithms:
1.start
2.Define : a,b,c.d,r1(float),r2(float).
3.Input : a,b,c from the user.
4. Calculate:
d=(b*b) -(4*a*c)
if (a>c),r1=(-b+sqrt(d)/(2*a);
r2=(-b-sqrt(d)/(2*a);
5.print the result as r1/r2 else the root is imaginary if d<0.
6.End.
Codes:
Outputs:
Compiling , Debugging and Testings
Enter a b c: 100 300 200
answer=-1 answer =-2