10)C PROGRAM TO FIND ROOTS OF THE QUADRATIC EQUATION:
SHOULD KNOW:- Quadratic Equation are in the form of ax2(x power 2)+bx+c=0 .Where a,b,c are real number and a!=0.
To find out root , first we find out the discriminant(D), which is equal to D=b2(b square) - 4ac.It gives nature of roots.
(a) if D>0 then the roots are real and different.
formula: roots1 = -b+sqrt(D)/2a and roots2 = -b-sqrt(D)/2a, where sqrt means square root of
(b) if D=0 then the roots are real and equal.
formula: roots1 = roots2 = -b/2a
(c) if D<0 then the roots are complex(means combination of real and imaginary number) and different.
formula: roots1 = (-b + i * sqrt(-D))/2a and roots2 = (-b - i *sqrt(-D))/2a
LOGIC:- as we find out in math simply find out in program, but here sqrt is function which required a header file math.h
EXAMPLE:-
TASK:"""FIND INTERSECTION OF TWO LINES"""
SHOULD KNOW:- Quadratic Equation are in the form of ax2(x power 2)+bx+c=0 .Where a,b,c are real number and a!=0.
To find out root , first we find out the discriminant(D), which is equal to D=b2(b square) - 4ac.It gives nature of roots.
(a) if D>0 then the roots are real and different.
formula: roots1 = -b+sqrt(D)/2a and roots2 = -b-sqrt(D)/2a, where sqrt means square root of
(b) if D=0 then the roots are real and equal.
formula: roots1 = roots2 = -b/2a
(c) if D<0 then the roots are complex(means combination of real and imaginary number) and different.
formula: roots1 = (-b + i * sqrt(-D))/2a and roots2 = (-b - i *sqrt(-D))/2a
LOGIC:- as we find out in math simply find out in program, but here sqrt is function which required a header file math.h
EXAMPLE:-
TASK:"""FIND INTERSECTION OF TWO LINES"""
Comments
Post a Comment