Posted By:
21 Jun, 2013 9:24 am PDT

function in c

How to find the roots of a quadratic equation?

A quadratic equation is of the form ax2+bx+c.

To find the root we first find d which is equal to b*b-4*a*c.

If d<0 then the roots are imaginary. If d==0 then roots are equal i.e. r1=r2=-b/(2*a)

Else r1=(-b+sqrt(d))/2*a and r2=(-b-sqrt(d))/2*a


Please see the video for more details......

Attachment: quadraticaeqn.c
Was it useful?  

First we need to find the discriminant which is discriminant=b*b - 4*a*c. So , depending on the value of discriminant , we can find the roots easily . 

If Discriminat D >0 the roots are real.

If D<0 , roots are imaginary

The formula for finding out the roots are root1=(-b+sqrt(b*b-(4*a*c))/(2*a))



We need to use the functions present in MATH.H header file. for this we need to include the <math.h> header file. 


please have a look at the attached file to understand the program to supplement your understanding of the video file above.


Was it useful?  

Please login to reply to this problem.

Related Problems on Fixoncloud