C Program to solve equations using Jordan elimination method.

Write a C Program to solve equations using Jordan elimination method.
Gauss-Jordan elimination method is used to solve the linear equations. In this method, We find the inverse matrix of the coefficients of equations by elementary row operations. Read more about C Programming Language . and read the C Programming Language (2nd Edition) by K and R.

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#include<conio.h>
void solution( int a[][], int var );
int main()
{

int a[ 20 ][ 20 ], var, i, j, k, l;
clrcsr();
printf( "nEnter the number of variables:n" );
scanf( "%d", &var );

for ( i = 0;i < var;i++ )
{
printf( "nEnter the equation%d:n", i + 1 );

for ( j = 0;j < var;j++ )
{
printf( "Enter the coefficient of x%d:n", j + 1 );
scanf( "%d", &a[ i ][ j ] );
}

printf( "nEnter the constant:n" );
scanf( "%d", &a[ i ][ n ] );
}

solution( a, var );
return 0;
}



void solution( int a[ 20 ][ 20 ], int var )
{
int k, i, l, j;

for ( k = 0;k < var;k++ )
{
for ( i = 0;i <= var;i++ )
{
l = a[ i ][ k ];

for ( j = 0;j <= var;j++ )
{
if ( i != k )
a[ i ][ j ] = a[ k ][ k ] * a[ i ][ j ] – l * a[ k ][ j ];
}
}
}

printf( "nSolutions:" );

for ( i = 0;i < n;i++ )
{
printf( "nTHE VALUE OF x%d IS %fn", i + 1, ( float ) a[ i ][ n ] / ( float ) a[ i ][ i ] );
}

}
Read more Similar C Programs
Learn C Programming
Recursion
Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com