This C program implements Gauss Jordan Elimination method. In linear algebra, Gaussian elimination is an algorithm for solving systems of linear equations.

Here is the source code of the C program to find solution of a system of linear equations. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`#include<stdio.h>`

void solution( int a[][20], int var );

int main()

`{`

int a[ 20 ][ 20 ], var, i, j, k, l, n;

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 ][ var] );

`}`

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 < var;i++ )

`{`

printf( "\nTHE VALUE OF x%d IS %f\n", i + 1, ( float ) a[ i ][ var ] / ( float ) a[ i ][ i ] );

`}`

`}`

$ gcc bubblesort.c -o bubblesort $ ./bubblesort Enter the number of variables: 3 Enter the equation 1: Enter the coefficient of x1: 1 Enter the coefficient of x2: 0 Enter the coefficient of x3: 0 Enter the constant: 2 Enter the equation 2: Enter the coefficient of x1: 0 Enter the coefficient of x2: 1 Enter the coefficient of x3: 0 Enter the constant: 0 Enter the equation 3: Enter the coefficient of x1: 0 Enter the coefficient of x2: 0 Enter the coefficient of x3: 1 Enter the constant: -1 Solutions: THE VALUE OF x1 IS 2.000000 THE VALUE OF x2 IS 0.000000 THE VALUE OF x3 IS -1.000000

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data Structures and Algorithms.