-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuadratic.c
More file actions
47 lines (35 loc) · 733 Bytes
/
Quadratic.c
File metadata and controls
47 lines (35 loc) · 733 Bytes
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
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <math.h>
#include <conio.h>
int Quadratic(int a, int b, int c)
{
float X, x, d;
d = sqrt(b * b - 4 * a * c);
X = (-b + d) / (2.0 * a);
x = (-b - d) / (2.0 * a);
if (X == x)
{
printf("Both roots are same : %0.3f", X);
}
else
{
printf("Roots are : %0.3f and %0.3f", X, x);
}
return 0;
}
int main()
{
int a, b, c;
printf("Enter constants of Quadratic equation a , b & c : \n");
scanf("%d%d%d", &a, &b, &c);
if (b * b < 4 * a * c)
{
printf("Roots of this equation are imaginaray");
}
else
{
printf("Root of this equation are real\n");
Quadratic(a, b, c);
}
return 0;
}