Sei sulla pagina 1di 1

#include<stdio.

h>
#include<conio.h>
#include<math.h>
int main()
{
int EQ,E1,y,x,k;
float a[100][100],c;
clrscr();
printf("Enter the number of equations to be solve:");
scanf("%d",&EQ);
printf("The size of the matrix is a %d x %d\n",EQ,EQ);
printf("Coefficients of each Equations:\n");
for(y=1;y<=EQ;y++)
{
printf("EQUATION:%d\n",y);
for(x=1;x<=EQ;x++)
{
printf("\nEnter %d row %d col element\n ",y+1,x+1);
scanf("%f",&a[y][x]);
}
}
printf("Please press enter to view the matrix.\n");
getch();
for(y=0;y<EQ;y++)
{
for(x=0;x<=EQ;x++)
printf("%6.1f",a[y][x]);
printf("\n");
}
getch();
for(k=0;k<EQ-1;k++)
for(y=k;y<EQ-1;y++)
{
c= (a[y+1][k]/a[k][k]) ;
for(x=0;x<=EQ;x++)
a[y+1][x]-=c*a[k][x];
}
printf("\n\n");
for(y=0;y<EQ;y++)
{
for(x=0;x<=EQ;x++)
printf("%6.1f",a[y][x]);
printf("\n");
}
getch();
}

Potrebbero piacerti anche