Showing posts with label Solution of Equations. Show all posts
Showing posts with label Solution of Equations. Show all posts

Monday, October 26, 2009

PROGRAM TO FIND THE SOLUTION OF ALGEBRIC EQUATIONS USING GAUSS-SEIDEL ITERATIVE METHOD

// SHUAIB SARKAR
// PROGRAM TO FIND THE SOLUTION OF
// ALGEBRIC EQUATIONS USING GAUSS-SEIDEL ITERATIVE METHOD

#include"stdio.h"
#include"conio.h"
#include"math.h"
#define FUNCX(y,z) (17-y+2*z)/20
#define FUNCY(x,z) (-18-3*x+z)/20
#define FUNCZ(x,y) (25-2*x+3*y)/20
void main()
{
float x1,y1,z1;
float a,b,c;
float x2,y2,z2;
int itr=1;
clrscr();
printf("\n\t\t\t GAUSS - SEIDEL ITERATION METHOD");
printf("\n\t\t\t=================================\n");
printf("\n\t\t\tValue Of X\t Value of Y\tValue of Z");
printf("\n======================================================");
x1=y1=z1=0;
do
{
a=FUNCX(y1,z1);
x2=x1;
x1=a;
b=FUNCY(x1,z1);
y2=y1;
y1=b;
c=FUNCZ(x1,y1);
z2=z1;
z1=c;
printf("\n Iterration : %d \t %f\t %f\t%f ",itr++,a,b,c);
}while(a!=x2 && b!=y2 && c!=z2);
printf("\n =====================================================");
printf("\n SOLUTION IS : \n\n X = %f \t Y= %f\t Z= %f",a,b,c);
getch();
}