This is a C Program to solve linear equation in one variable.
Here is source code of the C Program to Solve any Linear Equation in One Variable. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
#include <stdio.h>
#include <string.h>
float solve_for_y(float a, float b, float c) {
float Y = Y = -(b + c) / a;
return Y;
}
int main(int argc, char **argv) {
float a, b, c, Y;
printf(
"\nEnter a linear equation in one variable of the form aY + b + c = 0 ");
printf("\nEnter the value of a, b, c respectively: ");
scanf("%f%f%f", &a, &b, &c);
Y = solve_for_y(a, b, c);
printf("\nSolution is Y = %f", Y);
return 0;
}
Output:
$ gcc SolveLinearEquation.c $ ./a.out Enter a linear equation in one variable of the form aY + b + c = 0 Enter the value of a, b, c respectively: 2 4 8 Solution is Y = -6.000000
Sanfoundry Global Education & Learning Series – 1000 C Programs.
advertisement
Here’s the list of Best Books in C Programming, Data Structures and Algorithms.
Related Posts:
- Practice BCA MCQs
- Apply for C Internship
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check Computer Science Books