PRACTICAL- 5
Aim of the
practical:-
Write a program (WAP) to enter the value of Coefficient
of x2 (a), Coefficient of x (b) and constant term (c), and find the roots of a quadratic equation ax2+bx+c=0
Header files used:-
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
#include <math.h>
Conditional statements/Loops
used:-
i.
If– else –if ladder
Procedures followed:-
The coefficient of x2,
x, and constant term of the quadratic equation ax2 + bx + c = 0 is entered by the user. Then we find the discriminant
by applying the formula D=b2 - 4ac.
Then this discriminant is
compared with 0 in an if- else- if ladder and the roots are found as per the
rules given below.
i.
D>0, Roots are
real and distinct.
ii.
D=0, Roots are
real and equal.
iii.
D<0, Roots are
imaginary.
Coding:-
No comments:
Post a Comment