-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEquation_solver.c
More file actions
78 lines (56 loc) · 2.03 KB
/
Equation_solver.c
File metadata and controls
78 lines (56 loc) · 2.03 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// With the help of this code we can find the solution of linear equation having two variable ..(also two equations )
/*Here in this code we are taking two equation as 1) aA + bB = w and 2) xA + yB = v
by this two equation we are going to find the values of two variable A & B
*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
// This is function to find the values of variable and print them using main function ..
float Equationsolve(int c, int d, int e, int f, int g, int h)
{
float A, B;
if (d * f == g * c)
{
if ((d * h == g * e) || (c * h == f * e))
{
printf("The system of linear equations have many solutions.\n");
}
else
{
printf("The system of linear equation have no solutions.\n");
}
}
else
{
if (d * f != g * c)
{
printf("The system of linear equation have Unique solutions.\n");
A = ((d * h - g * e)) * 1.0 / ((d * f - g * c)) * 1.0;
B = ((c * h - f * e)) * 1.0 / ((c * g - f * d)) * 1.0;
printf("A is = %f\nB is = %f", A, B);
}
else
{
printf("Error\n");
}
}
return 0;
}
int main()
{
// taking six constants as there are two equations we need three-three constants per equation ..
int a, b, w, x, y, v;
// Taking input for the constant of first equation named a ,b and w
printf("Enter value of constant a , b and w : ");
scanf("%d%d%d", &a, &b, &w);
// It will gonna print the first equation ..
printf("Equation first is %dA + %dB = %d\n", a, b, w);
// Taking input for the constant of second equation named x, y and v
printf("Enter value of constant x , y and v : ");
scanf("%d%d%d", &x, &y, &v);
// It will gonna print the second equation ..
printf("Equation second is %dA + %dB = %d\n", x, y, v);
// Here we are recalling the above function we made to print the values of variable using main function ....
Equationsolve(a, b, w, x, y, v);
return 0;
}