To calculate the root of quadratic number

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,r1,r2,t;
clrscr();
printf("enter the value of a,b,c\n");
scanf("%f%f%f",&a,&b,&c);
t=b*b-4*a*c;
if(t<0)
printf("root are imaginary\n");
else
{
r1=(-b+sqrt(t))/(2*a);
r2=(-b-sqrt(t))/(2*a);
printf("\n root1=%f",r1);
printf("\n root2=%f",r2);
}
getch();
}

Comments

Post a Comment