-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quardratic.c
39 lines (35 loc) · 875 Bytes
/
Quardratic.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
#include<conio.h>
int main()
{
float a,b,c,root1,root2,rpart,ipart,disc;
printf("Enter the three cofficients: \n");
scanf("%f%f%f",&a,&b,&c);
if(a*b*c==0)
{
printf("Roots cannot be Determined: \n");
exit(0);
}
disc=(b*b)-(4*a*c);
if(disc==0)
{
printf("Roots are equal\n");
root1=root2=-b/(2*a);
printf("root1 = root2 = %f",root1);
}
else if(disc>0)
{
printf("Roots are real and distinct \n");
root1=(-b+sqrt(disc))/(2*a);
root2=(-b-sqrt(disc))/(2*a);
printf("root1 = %f\n root2 = %f \n",root1,root2);
}
else
{
printf("Roots are complex \n");
rpart = -b/(2*a);
ipart = (sqrt(-disc))/(2*a);
printf("root1 = %f+i%f\n",rpart,ipart);
printf("root2 = %f-i%f\n",rpart,ipart);
}
}