Check the program  by executing them once 

Practical  Note Book.docx Practical Note Book.docx
Size : 51.147 Kb
Type : docx

 Project (Both Civil and CSE)

Gauss-Seidel Method

#include<stdio.h>

#include<conio.h>

#include<math.h>

#define ESP 0.0001

#define X(Y,Z) ((17 - 20*(Y) + 2*(Z))/20)

#define Y(X,Z) ((-18 - 3*(X) + (Z))/20)

#define Z(X,Y) ((25 - 2*(X) + 3*(Y))/20)



int  main()

{

  float  X=0 , Y=0 , Z=0 , X1,Y1,Z1;

  int i=0;

  //clrscr();

  printf("\n__________________________________________\n");

  printf("\n   x1\t\t   x2\t\t   x3\n");

  printf("\n__________________________________________\n");

  printf("\n%f\t%f\t%f",X,Y,Z);

  do

  {

   X1=X(Y,Z);

   Y1=Y(X1,Z);

   Z1=Z(X1,Y1);

   if(fabs(X1-X)<ESP && fabs(Y1-Y)<ESP && fabs(Z1-Z)<ESP )

   {

     printf("\n__________________________________________\n");

     printf("\n\nx1 = %f",X1);

     printf("\n\nx2 = %f",Y1);

     printf("\n\nx3 = %f",Z1);

     i = 1;

   }

   else

   {

     X = X1;

     Y = Y1;

     Z = Z1;

     printf("\n%f\t%f\t%f",X1,Y1,Z1);

   }

  }while(i != 1);

getch();


return 0;

}


 

Make a free website with Yola