Here you get a program that calculate the solution of quadric equation......

main()

{

disc = b*b - 4 * a * c ;

if(disc >0 )

{

x1= (-b + sqrt(disc))/ (2 * a);

x2 = (-b - sqrt(disc))/(2*a);

printf("

}

}

{

x1= -b /(2*a) ;

x2 =

}

}

}

**#include <stdio.h>;****#include <conio.h>;**main()

{

**float**a,b,c,x1,x2,disc;**clrscr()**;**printf(**"*Enter the value of a,b,c:*"**)**;**scanf(**"*%f%f%f*",&a,&b,&c**)**;disc = b*b - 4 * a * c ;

if(disc >0 )

{

x1= (-b + sqrt(disc))/ (2 * a);

x2 = (-b - sqrt(disc))/(2*a);

printf("

*\nThe root are distinct\nAndvalue are as follows:\nx1 = %f\nx2 =%f*",x1,x2);}

**if(**disc == 0**)**{x1=x2=-b/(2*a);**printf**("*\nRoot are equal and value of x1=x2=%f*",x1);}

**if**(disc <0){

x1= -b /(2*a) ;

x2 =

**sqrt**(**fabs**(disc));**printf**("*\nRoot are complex. Values are:\nx1=%f\nx2=%f*",x1,x2);}

**getch()**;}

}

## 0 comments:

## Post a Comment