Tweet
// Gauss-Seidal Method
#include<stdio.h>
main()
{
int n,i,j,k;
float a[20][20],x[20],m,s=0.0;
printf("\nProgram to implement Gauss-Seidal Iterative Method : \n");
printf("\nEnter the order of the co-efficient matrix : ");
scanf("%d",&n);
printf("\nEnter the element of the augmented matrix row-wise : ");
for(i=1;i<=n;i++)
for(j=1;j<=n+1;j++)
scanf("%f",&a[i][j]);
printf("\nEnter the initial approximation : ");
for(i=1;i<=n;i++)
scanf("%f",&x[i]);
for(k=1;k<=15;k++)
{
for(i=1;i<=n;i++)
{
s=a[i][n+1];
for(j=1;j<=n;j++)
{
if(j!=i)
s=s-a[i][j]*x[j];
}
x[i]=s/a[i][i];
}
}
printf("\nThe required soln :\n");
for(i=1;i<=n;i++)
printf("x[%d] = %6.4f\n",i,x[i]);
}
Gauss - Seidal Method in C
Posted by
LAHAUL SETH
~
Gauss - Seidal Method in C
2011-12-23T08:51:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|
Comments
Gauss - Seidal Method in C
2011-12-23T08:51:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|