Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If you are not expert, please don\'t answer it, For the following program, you s

ID: 3859146 • Letter: I

Question

If you are not expert, please don't answer it,

For the following program, you should run each of them using Dev-C++. You answer should include screen shots of your code and program outputs as text. Your programs must be commented. Write a complete C language program that implements Naive Gauss Elimination method to solve a set of linear simultaneous equations represented by the following matrix equation: [3.2 -1 -1.5 0 -1.4 3.1 0 -1 -1.3 0 2.4 0 0 -1 0 3.1] [x_1 x_2 x_3 x_4] = [5.2 0 -6.1 6.1] Your program should prompt the user to enter the number of equations to be solved and the coefficients of each equation, one equation at a time, and displays the results on the console.

Explanation / Answer

#include<stdio.h>
#include<windows.h>

int main()
{
int i,j,k,n;
float A[20][20],c,x[10],sum=0.0;
printf(" Enter the quantity of equation to find ");
scanf("%d",&n);
printf(" Enter the elements for each field ");
  
  
  
   for(i=1; i<=n; i++) //with these for loops we go throw of the matrix and assing the number to the field
                       //for example to the field A[1],[1] assing number 2
{
for(j=1; j<=(n+1); j++)
{
printf("A[%d][%d] : ", i,j);
scanf("%f",&A[i][j]);
}
}


for(j=1; j<=n; j++) /* with these lopp we generate the upper triangular matrix (A upper triangular matrix is a matrix which coefficients are located over the principal diagonal )*/
{
for(i=1; i<=n; i++)
{
if(i>j)
{
c=A[i][j]/A[j][j];
for(k=1; k<=n+1; k++)
{
A[i][k]=A[i][k]-c*A[j][k];
}
}
}
}

x[n]=A[n][n+1]/A[n][n];
/* this loops solves the equations*/
for(i=n-1; i>=1; i--)
{
sum=0;
for(j=i+1; j<=n; j++)
{
sum=sum+A[i][j]*x[j];
}
x[i]=(A[i][n+1]-sum)/A[i][i];
}
printf(" The solution is: ");
for(i=1; i<=n; i++)
{
printf(" x%d=%f ",i,x[i]); /* */
   system("pause");
}
return(0);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote