-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDharacharyaMethod.c
More file actions
52 lines (42 loc) · 1.1 KB
/
DharacharyaMethod.c
File metadata and controls
52 lines (42 loc) · 1.1 KB
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
48
49
50
51
52
#include <stdio.h>
#include <math.h>
double dharacharya1(double a, double b, double c)
{
double root1_a = (-b) / 2 * a;
double root1_b = sqrt(b * b - 4 * a * c) / 2 * a;
return (root1_a + root1_b);
}
double dharacharya2(double a, double b, double c)
{
double root1_a = (-b) / 2 * a;
double root1_b = sqrt(b * b - 4 * a * c) / 2 * a;
return (root1_a - root1_b);
}
int main()
{
double a = 1, b = -3000.001, c = -3;
double roots1 = dharacharya1(a, b, c);
double roots2 = dharacharya2(a, b, c);
printf("%lf\n", roots1);
printf("%lf\n", roots2);
}
float dharacharya1(float a, float b, float c)
{
float root1_a = (-b) / 2 * a;
float root1_b = sqrt(b * b - 4 * a * c) / 2 * a;
return (root1_a + root1_b);
}
float dharacharya2(float a, float b, float c)
{
float root1_a = (-b) / 2 * a;
float root1_b = sqrt(b * b - 4 * a * c) / 2 * a;
return (root1_a - root1_b);
}
int main()
{
float a = 1, b = -3000.001, c = -3;
float roots1 = dharacharya1(a, b, c);
float roots2 = dharacharya2(a, b, c);
printf("%f\n", roots1);
printf("%f\n", roots2);
}