Question: I have this Gouss Jorden elimination solver code in C that isn't complate. I Just need to add few more lines to it to make

I have this Gouss Jorden elimination solver code in C that isn't complate. I Just need to add few more lines to it to make it work and give me the output below. Also, could you please help me calculate the time complixity for the code. Thank you.

Code:

#include
int main()
{
// Declare Vairables
int i,j,k,n;
float // You'll need a few more variables, but only one matrix
// Request System Order (Number of Equtions)
printf(" How many equations: ");
scanf("%d",&n);
// Allocate Dynamic Veriables
// (psst... malloc is pretty good at this)
// Request Augmented Matrix Values
printf(" Enter the elements of augmented matrix row-wise: ");
for(i=1; i
{
for(j=1; j
{
printf(" A[%d][%d]:", i,j);
scanf("%f",&A[i][j]);
}
}
// Diagnolize the matrix
for(j=1; j
{
for(i=1; i
{
if(i!=j)
{
// There is a useful intermediate value you can compute here
for(k=1; k
{
// This is where the magic happens
}
}
}
}
printf(" The solution is: ");
for(i=1; i
{
// One last math - compute the unknown from the diag and constant
printf(" x%d=%f ",i,x[i]);
}
return(0);

}

Output:

I have this Gouss Jorden elimination solver code in C that isn't

How many equations: 3 Enter the elements of augmented matrix row-wise: A [1] 04]9 A [2] 01]:3 ? [2] [2] :6 A [2] [3] :0 A [2] [4]:-9 A [3] 01]9 A [3] [2]:3 A [3] [3]:-2 A [3] [4]:-1 The solution is: x1-0.224806 x2--1.612403 x3--0.906976

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!