#include<
#include<
int main()
{
int n=3,i,j,k;
float a[10][10],c[10],x[10];
printf("Enter the no. of equations :\n");
scanf("%d", &n);
printf("Enter the right hand side of equation ");
for(i=0;i<=n-1;i++)
{
scanf("%f",&c[i]);
}
for(i=0;i<=n-1;i++)
{
printf("Enter the coefficient of equation %d.\n",i+1);
for(j=0;j<=n-1;j++)
{
scanf("%f",&a[i][j]);
}
}
for(k=0;k<=n-2;k++)
{
for(i=k+1;i<=n-1;i++)
{
for(j=k+1;j<=n-1;j++)
{
a[i][j]=a[i][j]-((a[i][k]/a[k][k])*a[k][j]);
}
c[i]=c[i]-((a[i][k]/a[k][k])*c[k]);
}
}
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
{
printf("%f ",a[i][j]);
}
printf("\n");
}
printf("\n");
x[n-1]=c[n-1]/a[n-1][n-1];
printf("The solution is :\n");
printf("x[%d] = %f\n",n-1,x[n-1]);
for(k=0;k<=n-2;k++)
{
i=n-k-2;
for(j=i+1;j<=n-1;j++)
{
c[i]=c[i]-(a[i][j]*x[j]);
}
x[i]=c[i]/a[i][i];
printf("x[%d] = %f\n",i,x[i]);
}
return 0;
}
Nov 18, 2008
0
Guass Elimination Method
Posted by
bikash pradhan
at
8:27 AM
Subscribe to:
Posts (Atom)
Search
Programs
- backward difference formula c program code (1)
- Bisection Method c program code (1)
- Cramers rule (1)
- False position (1)
- Forward Difference Formula c program code (1)
- Gauss Seidal Method c program code (1)
- Guass Elimination Method c program code (1)
- Method of Successive Approximation c program code (1)
- Newton Raphson Method c program code (1)
- Newton's Backward Interpolation Formula c program code (1)
- Newton's Forward Interpolation Formula c program code (1)
- Regula Falsi on False Position Method c program code (1)
- Simpson's 1/3 Rule c program code (1)
- Simpson's Simpsons' 3/8 rule c program code (1)
- Trapezoidal Rule C program code (1)