#include<stdio.h>
#include<conio.h>
void main()
{
float a, b, c, d, root, root1, root2;
clrscr();
printf("Enter a, b and c");
scanf("%f %f %f", &a, &b, &c);
d=b*b-4*a*c;
if(d<0)
{
printf("\n Roots are imaginary");
}
else if(d==0)
{
root=-b/2*a;
printf("\n Root = %f",root);
}
else
{
root1 = (-b+sqrt(d))/(2*a);
root2 = (-b-sqrt(d))/(2*a);
printf("Root1 = %.2f \n Root2 = %.2f",root1,root2);
}
getch();
}
No comments:
Post a Comment