I need help in creating the backward substitution of gaussian elimination. I can't quite get it. Help is greatly appreciated.
Here is my code
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void input(float d[100][100]);
void display_matrix();
main(){
float A[100][100],B[100],c1,c2;
int v,w,x,y,z;
clrscr();
printf("Input the number of equations: ");
scanf("%d",&z);
printf("\nInput the coefficients and constants: ");
for(x=0;x<z;x++)
for(y=0;y<=z;y++)
{
scanf("%f",&B[y]);
A[x][y]=B[y];
}
free(B);
printf("\n");
display_matrix(A,&z);
for(v=0,w=0;v<z;v++,w++)
for(x=v+1;x<z;x++)
{
c1=A[v][w];
c2=A[x][w];
for(y=0;y<=z;y++)
A[x][y]=(c1*A[x][y]) - (c2*A[v][y]);
display_matrix(A,&z);
printf("\n...Press any key to proceed to next step...\n");
getch();
}
getch();
}
void display_matrix(float d[100][100],int *z1)
{
int x,y;
printf("\n");
for(x=0;x<*z1;x++)
{
for(y=0;y<=*z1;y++)
printf("%.2f\t",d[x][y]);
printf("\n");
}
printf("\n");
}