Search:

Submit Article

# GUASS JORDEN ELIMINATION METHOD

Posted By: Emma Campbell     Category: C Programming     Views: 5330

## Code for GUASS JORDEN ELIMINATION METHOD in C Programming

```#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float mat[4][4],temp,temp1,x,y,z;
int i,n=3,j;
//  clrscr();for(i=0; i<n; i++)
{
printf("\n\nenter the value of %d eqvation",i+1);
for(j=0; j<n; j++)
{
printf("\nenter the value of coeffcient %d: ",j+1);
scanf("%f",&mat[i][j]);
}
printf("\nenter the value of constent: ");
scanf("%f",&mat[i][j]);
}

printf("\n* * * Your Matrix * * *\n\n");
for(i=0;i<n;i++)
{
for(j=0;j<n+1;j++)
{
printf(" %g ",mat[i][j]);
}
printf("\n\n");
}

temp=mat[1][0]/mat[0][0];
temp1=mat[2][0]/mat[0][0];
for(i=0,j=0;j<n+1;j++)
{
mat[i+1][j]=mat[i+1][j]-(mat[i][j]*temp);
mat[i+2][j]=mat[i+2][j]-(mat[i][j]*temp1);
}

temp=mat[2][1]/mat[1][1];
temp1=mat[0][1]/mat[1][1];
for(i=1,j=0;j<n+1;j++)
{
mat[i+1][j]=mat[i+1][j]-(mat[i][j]*temp);
mat[i-1][j]=mat[i-1][j]-(mat[i][j]*temp1);
}

temp=mat[0][2]/mat[2][2];
temp1=mat[1][2]/mat[2][2];
for(i=0,j=0;j<n+1;j++)
{
mat[i][j]=mat[i][j]-(mat[i+2][j]*temp);
mat[i+1][j]=mat[i+1][j]-(mat[i+2][j]*temp1);
}

for(i=0;i<n;i++)
{
for(j=0;j<n+1;j++)
{
printf(" %.3f ",mat[i][j]);
}
printf("\n\n");
}

z = mat[2][3]/mat[2][2];
y = mat[1][3]/mat[1][1];
x = mat[0][3]/mat[0][0];
printf("\n\nx = %.3f",x);
printf("\n\ny = %.3f",y);
printf("\n\nz = %.3f",z);

getch();
}

/*______________________________________             OUT PUT______________________________________enter the value of 1 eqvationenter the value of coeffcient 1: 2enter the value of coeffcient 2: 1enter the value of coeffcient 3: 1enter the value of constent: 10enter the value of 2 eqvationenter the value of coeffcient 1: 3enter the value of coeffcient 2: 2enter the value of coeffcient 3: 3enter the value of constent: 18enter the value of 3 eqvationenter the value of coeffcient 1: 1enter the value of coeffcient 2: 4enter the value of coeffcient 3: 9enter the value of constent: 16* * * Your Matrix * * * 2  1  1  10 3  2  3  18 1  4  9  16 2.000  0.000  0.000  14.000 0.000  0.500  0.000  -4.500 0.000  0.000  -2.000  -10.000x = 7.000y = -9.000z = 5.000*/```
Share:

Didn't find what you were looking for? Find more on GUASS JORDEN ELIMINATION METHOD Or get search suggestion and latest updates.

 Emma Campbell author of GUASS JORDEN ELIMINATION METHOD is from Toronto, Canada. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!