Gauss Elimination Method

Source Code:

Write a program in C to solve the system of equations using the Gauss Elimination Method: 𝟐𝒙 + 𝒚 − 𝒛 = 𝟖 − 𝟑𝒙 − 𝒚 + 𝟐𝒛 = −𝟏𝟏 − 𝟐𝒙 + 𝒚 + 𝟐𝒛 = −3

#include <stdio.h>
#include <conio.h>
int main(){
 clrscr();
 int i,j,k; double a[3][4]={{2,1,-1,8},{-3,-1,2,-11},{-2,1,2,-3}},x[3],f;
 for(k=0;k<3;k++){
 for(i=k+1;i<3;i++){
 f=a[i][k]/a[k][k];
 for(j=k;j<4;j++) a[i][j]-=f*a[k][j];
 }
 }
 for(i=2;i>=0;i--){
 x[i]=a[i][3];
 for(j=i+1;j<3;j++) x[i]-=a[i][j]*x[j];
 x[i]/=a[i][i];
 }
 printf("\n");
 for(i=0;i<3;i++) printf("\tx%d=%.2f\n",i+1,x[i]);
 getch();
 return 0;
} 

Output