Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C program toe find the roots of a quadratic equation.



#include<math.h>

void main()
{
float a,b,c,root1,root2;
clrscr();
printf("\n Enter values of a,b,c for finding roots of a quadratic eq:\n");
scanf("%f%f%f",&a,&b,&c);

/*checking condition*/
if(b*b>4*a*c)
{
 root1=-b+sqrt(b*b-4*a*c)/2*a;
 root2=-b-sqrt(b*b-4*a*c)/2*a;
 printf("\n*****ROOTS ARE*****\n");
 printf("\n root1=%f\n root2=%f",root1,root2);
}
else
 printf("\n Imaginary Roots.");
 getch();
}



This post first appeared on C Programs, please read the originial post: here

Share the post

C program toe find the roots of a quadratic equation.

×

Subscribe to C Programs

Get updates delivered right to your inbox!

Thank you for your subscription

×