Click below to view this site using some new reading style

** Classic | Flipcard | Magazine | Mosaic | Sidebar | Snapshot | Timeslide **

Gauss Jacobi Iteration Method

10:13 AM Posted In Edit This 0 Comments »

#include<stdio.h>
#include<conio.h>
#include<math.h>

Technorati Tags:

#define pf printf
#define sf scanf
main(){int n,i,j,k;
float a[20][20],x[20],s;
pf("enter the order of co eficient : \n");
sf("%d",&n);
pf("enter element of the augmented matrix : \n");
for(i=1;i<=n;i++){
for(j=1;j<=n+1;j++)
sf("%f",&a[i][j]);}
pf("enter the initial approximation : \n");
for (i=1;i<=n;i++)
sf("%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];
                                     }
                                     }
pf("the required sol is : \n");
for(i=1;i<=n;i++)
pf("x[%d] = %6.4f \n",i,x[i]);
getch();
}
© Ramen Mukherjee

Thank You Miss Nishat Parveen Smile

0 comments: