0

Hi,please help me!

I wanna write a program for gauss jordon elimination ,for that I need to sort/exchange the rows such that the rows are in order of their increasing

zero elements before non zero element in each row like below

```
suppose,
input 0 0 3 4 5
0 3 2 1 6
0 0 0 2 0
6 2 0 3 1
output should be 6 2 0 3 1
0 3 2 1 6
0 0 3 4 5
0 0 0 2 0
```

I have tried this, but is not working properly,please suggest/correct .

```
#include<stdio.h>
main(){
int i,j,k,l,m,n,o,p,q,r,s,t,u,len,count=0;
printf("Enter no.of unknowns:");
scanf("%d",&m);
printf("Enter no.of equations:");
scanf("%d",&n);
float a[m][n+1],v; //I took n+1 because columns=rows+1,which includes value column of equations of gauss jordon
int b[m];
for(i=0;i<m;i++){ //reading elements
for(j=0;j<(n+1);j++){
printf(" ",i+1,j+1);
scanf("%f",&a[i][j]);
}
printf("\n");
}
for(i=0;i<m;i++){ //counting no.of zeros
count=0;
for(j=0;(a[i][j]==0)&&(j<(n+1));j++){
}
b[i]=j;
printf("%d ",b[i]);
}
putchar('\n');
for(k=0;k<m;k++) //sorting starts here
for(i=0;i<(m);i++){
if(b[i]>b[i+1]){
for(j=0;j<n+1;j++){
v=a[i+1][j];
a[i+1][j]=a[i][j];
a[i][j]=v;
}
}
}
for(i=0;i<m;i++){ //printing
for(j=0;j<(n+1);j++){
printf("%.2f ",a[i][j]);
}
printf("\n");
}
getch();
}
```

THANKS IN ADVANCE!

*Edited 3 Years Ago by Reverend Jim*: Fixed formatting