Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started