Hi,

Please tell me the c code for finding a basic solution to a system of linear equations!Please help me as I am messed with the Gauss-Jordan Method.I am not getting the correct idea to do this in my project. Please help me soon.

Where is it, you are getting stuck with it in your code?

Hi Dani,

yeah,but the fact is that I am using mathematics related programs like this for the first times.So don't know,what to do. Actually there are n number of unkowns and m number of equation.So we have to initialize 0 to remaining elements other than n-m numbers.If you have the idea based on this program please share with me.If possible,please update that program soon.

Show the equations you need to use, and show the code you are trying to get to express them - as well as all required inputs and outputs.

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

int a[ 20 ][ 20 ], var, i, j, k, l,n=0;
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,n=0;

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 ] * a[ k ][ j ];
}
}
}

printf( "\nSolutions:" );

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

}
``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.