Gauss elimination method
#include<stdio.h>
#include<conio.h>
int main(void)
{
int i,j;
float x,y,z,le[3][4];
clrscr();
printf("Enter the coefficient and const of the 3 linear eqn:");
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%f",&le[i][j]);
}
}
x=le[0][0];
for(j=0;j<4;j++)
le[0][j]/=x;
x=le[1][0],y=le[2][0];
for(j=0;j<4;j++)
{
le[1][j]-=x*le[0][j];
le[2][j]-=y*le[0][j];
}
x=le[1][1];
for(j=1;j<4;j++)
le[1][j]/=x;
x=le[2][1];
for(j=1;j<4;j++)
le[2][j]-=x*le[1][j];
z=le[2][3]/le[2][2];
y=le[1][3]-(le[1][2]*z);
x=le[0][3]-(le[0][2]*z)-(le[0][1]*y);
printf("Solution is:x=%.2f\ty=%.2f\tz=%.2f",x,y,z);
getch();
return 0;
}
