# Solution Of Simultaneous Equation

This program finds the solution of system of simulataneous equation Using GAUSS SEIDEL METHOD. This method is very popural among the students who studies Numerical Techniques.Though this program cant find the solution of every equations,it is widely used.This can only found the solutions of those equations which are Digonally dominant.

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

//////////////////////////////////////////////////////////////
/////////////     Programmer : Harsh Chandra    /////////////
////////////////////////////////////////////////////////////

void main()
{ clrscr();
float ar[10][10],s=0,x[10];
int i,j,n,k=12;
char m;
printf("ENTER THE NUMBER OF INDEPENDENT VARIABLES   :");
scanf("%d",&n);
printf("\nENTER THE ELEMENTS OF AUGMENTED MATRIX ROWWISE  :");
printf("\nFor Example :- First Eq :3x+2y+5z=4  ");
printf("\n\t\tInput 3 2 5 4 and so on...");
for(i=0;i<n;i++)
{
for(j=0;j<n+1;j++)
{  printf("\nEnter the (%d,%d)th element:",i,j);
scanf("%f",&ar[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{  if(i!=j)
{  s+=abs(ar[i][j]);
}
}
if(abs(ar[i][i])<s)
k=0;
s=0;
}
if(k!=12)
{  printf("\n\nTHE SYSTEM OF EQUATIONS YOU HAVE ENTERED CANNOT BE SOLVED BY GUASS SEIDEL METHOD AS IT IS NOT DIAGONALLY DOMINANT");
getch();
exit;
}
if(k==12)
{  for(i=0;i<n;i++)
x[i]=0;
do
{
for(i=0;i<n;i++)
{	x[i]=ar[i][n];
for(j=0;j<n;j++)
{ if(i!=j)
x[i]-=(ar[i][j]*x[j]);
}
x[i]=x[i]/ar[i][i];
}
for(i=0;i<n;i++)
printf("\nx[%d] = %f",i,x[i]);
printf("\nIs it accurate or u want to proceed(enter Y if u wanna proceed) : ");
m=getche();
}while(m=='y'|| m== 'Y');
}
getch();
}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.