#include
#include
int main()
{
int i,j,flag,n;
float a[10][10],y[10];
float sum,temp;
printf("Enter the no.s of equations.\n");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("Enter the coefficent & value of equations %d.",i+1);
for(j=0;j<=n;j++)
{
scanf("%f",&a[i][j]);
}
}
for(i=0;i<=n-1;i++)
{
x[i]=0;
y[i]=9999;
}
do
{
for(i=0;i<=n-1;i++)
{
sum=0;
for(j=0;j<=n-1;j++)
{
if(j!=i)
{
sum=sum+a[i][j]*x[j];
}
}
temp=(a[i][n]-sum)/a[i][i];
x[i]=temp;
}
for(i=0;i<=n-1;i++)
{
if(y[i]==x[i]) flag=1;
else flag =0;
}
for(i=0;i<=n-1;i++)
{
y[i]=x[i];
printf("x[%d]=%f\t",i,x[i]);
}
printf("\n");
}while(flag==0);
return 0;
}
Nov 18, 2008
Gauss Seidal Method
Posted by
bikash pradhan
at
8:24 AM
Subscribe to:
Post Comments (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)
0 comments:
Post a Comment