Professional Documents
Culture Documents
#include <stdio.h>
#include <stdlib.h>
// FUNCTION PROTOTYPES
int main()
int i,j,n;
scanf("%d",&n);
printf("Enter the coefficients of the matrix\nEnter them in row form separating each coefficient
with a space\n\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%lf",&mat[i][j]);
printf("Enter the coefficients of the vector on the RHS of the system in colon form\n\n");
for(i=0;i<n;i++)
scanf("%lf",&coef[i]);
}
for(i=0;i<n;i++)
if(mat[i][i]==0)
exit(1);
back_substitution(n,mat,coef);
return 0;
double multi;
int r,q,w;
for(r=0;r<(p-1);r++)
if(mat1[r][r]==0)
find_pivot(r,p,mat1,coef1);
}
for(q=(r+1);q<p;q++)
multi=(mat1[q][r])/(mat1[r][r]);
coef1[q]=coef1[q]-(multi*coef1[r]);
for(w=0;w<p;w++)
mat1[q][w]=mat1[q][w]-(multi*mat1[r][w]);
for(r=0;r<p;r++)
for(q=0;q<p;q++)
printf("\t%.2f",mat1[r][q]);
printf("\n");
for(r=0;r<p;r++)
printf("%.2f\n",coef1[r]);
double inter;
int e=0;
int s;
while(mat2[t][t]==0)
for(s=0;s<v;s++)
inter=mat2[t][t+s];
mat2[t][t+s]=mat2[t+e+1][t+s];
mat2[t+1+e][t+s]=inter;
inter=coef2[t];
coef2[t]=coef2[t+e+1];
coef2[t+e+1]=inter;
e++;
if(e==v)
exit(0);
return;
int b,c;
double x[y];
double sum;
for(b=0;b<y;b++)
{
x[b]=0;
for(b=y-1;b>=0;b--)
sum=coef3[b];
for(c=b+1;c<y;c++)
x[b]=sum/(mat3[b][b]);
for(b=0;b<y;b++)
printf("x%d = %.2f\n",(b+1),x[b]);