Who's Online

We have 27 guests and 1 member online

Login Form



RSS FEEDS



Solution to linear equation using Jordan Elimination PDF Print
User Rating: / 0
PoorBest 
Program Codes - C++ Programming
Written by Mansoorkhan   
Friday, 06 November 2009 03:02

#include
#include
int b[10][10],n;
float a[10][10];
void min(int r1,int r2,float no);
void mul(int r1,float no);
main()
{
int i,j;
clrscr();

printf("\n\nEnter no of variables : ");
scanf("%d",&n);
printf("\nEnter the values as a00 x1+a01 x2+.......+a0n-1 xn=a0n\n");
for(i=0;i < n;i++)
{
for(j=0;j < n+1;j++)
{
printf(" a%d%d : ",i,j);
scanf("%d",&b[i][j]);
a[i][j]=b[i][j];
}
}

for(j=0;j < n;j++)
{
if(a[j][j]!=1.0)
mul(j,a[j][j]);
for(i=0;i < n;i++)
{
if(i!=j&&a[i][j]!=0)
{
min(i,j,a[i][j]);
}
}}
printf("\n\n");
for(i=0;i < n;i++)
{
printf("x%d = %f \n",i+1,a[i][n]);
}
getch();
}

void min(int r1,int r2,float no)
{
int i,j,k;
for(i=0;i < n+1;i++)
{
a[r1][i]=a[r1][i]-no*a[r2][i];
}
}

void mul(int r1,float no)
{
int i;
for(i=0;i < n+1;i++)
a[r1][i]=a[r1][i]/no;
}

AddThis Social Bookmark Button
 

Copyright Disclaimer: This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.Thanks to Getkerala

For Latest Technology News and computer tips and tricks