/* Program to find the roots of a quadratic equation */

#include<stdio.h>

#include<math.h>

main()

{

int a,b,c,descr;

double root1,root2,part;

printf(“\nEnter the co-efficients of a quadratic equation: “);

scanf(“%d%d%d”,&a,&b,&c);

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

if(descr<0)

printf(“\nThe roots are imaginary!!\n\n”);

else

{

if(descr==0)

printf(“\nThe roots are equal!\n\n”);

else

printf(“\nThe roots are unique!\n\n”);

part=sqrt((b*b)-(4*a*c));

root1=(-b+part)/(2*a);

root2=(-b-part)/(2*a);

printf(“\nThe roots are…..\nRoot1= %7.3f\nRoot2= %7.3f\n\n”,root1,root2);

}

}

Advertisements

Tat is very usefull

Tat is simple