Thursday , August 17 2017
Home / C / How to Solve Linear Equation in One Variable In C Programming?

How to Solve Linear Equation in One Variable In C Programming?

C Program to Solve any Linear Equation in One Variable

Find complete C program to solve Linear equation in one variable. This is one of the most important mathematical programs for C to  know how to solve linear equation in C program.

#include <stdio.h>
#include <string.h>
float solve_for_y(float a, float b, float c)
{
 float Y = Y = -(b + c) / a;
 return Y;
}
main()
{
 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);
 
}
$ gcc linear_equation.c -o linear_equation
$ ./linear_equation
 
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

For more related C program examples like C program for solving linear equation in one variable, keep checking Program code examples.

Source – http://www.sanfoundry.com/c-programming-examples-numerical-problems-algorithms/

 

Check Also

Restrict Mouse Pointer Position C Graphics Program

This C Program will restrict the Mouse Pointer location or to a particular position or x,y ...

Leave a Reply

Your email address will not be published. Required fields are marked *