Gauss-Siedel Implementation Through C
Gauss-Siedel Implementation Through C :-
------------------------------
------------------------------
------------------------------
---------
#include<stdio.h>
#include<conio.h>
void main()
{
float x1,x2,x3,it1,it2,it3,a,b,c,d1,
i,j,k,d2,p,q,r,d3;
int m;
clrscr();
printf("Enter Coefficients For First Equation");
------------------------------
------------------------------
---------
#include<stdio.h>
#include<conio.h>
void main()
{
float x1,x2,x3,it1,it2,it3,a,b,c,d1,
i,j,k,d2,p,q,r,d3;
int m;
clrscr();
printf("Enter Coefficients For First Equation");
scanf("\n%f %f %f %f",&a,&b,&c,&d1);
printf("\nEnter Coefficient For second Equation");
scanf("\n%f %f %f %f",&p,&q,&r,&d2);
printf("Enter Coefficient For Thirs Equation");
scanf("\n%f %f %f %f",&i,&j,&k,&d3);
x1=0;
x2=0;
x3=0;
for(m=1;m<=5;m++)
{
it1=(d1-b*x2-c*x3)/a;
x1=it1;
it2=(d2-p*x1-r*x3)/q;
x2=it2;
it3=(d3-x1*i-x2*j)/k;
x3=it3;
printf("\nThe Three Coefficients Are X1= %f X2=%f and X3=%f",x1,x2,x3);
}
printf("\nThe Three Coefficients Are X1= %f X2=%f and X3=%f",x1,x2,x3);
getch();
}
printf("\nEnter Coefficient For second Equation");
scanf("\n%f %f %f %f",&p,&q,&r,&d2);
printf("Enter Coefficient For Thirs Equation");
scanf("\n%f %f %f %f",&i,&j,&k,&d3);
x1=0;
x2=0;
x3=0;
for(m=1;m<=5;m++)
{
it1=(d1-b*x2-c*x3)/a;
x1=it1;
it2=(d2-p*x1-r*x3)/q;
x2=it2;
it3=(d3-x1*i-x2*j)/k;
x3=it3;
printf("\nThe Three Coefficients Are X1= %f X2=%f and X3=%f",x1,x2,x3);
}
printf("\nThe Three Coefficients Are X1= %f X2=%f and X3=%f",x1,x2,x3);
getch();
}
!!! THANKS FOR READING !!!
!!!!!HAPPY PROGRAMMING !!!!!
!!!!!HAPPY PROGRAMMING !!!!!
Comments
Post a Comment