Question
Reposting since I got no answer last time.
I need help with this gauss elimination program

Hi, I need help with this program, its an algorythm in R. I need it to be done in c. #suppose ak! -0 k in step k ## Input da
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi there,

please find the solution.

----------------------------------------------

#include<stdio.h>
int main()
{
int a,b,c,n;
float A[20][20],d,x[10],sum=0.0;
printf("\nOrder of matrix: ");
scanf("%d",&n);
printf("\nEnter the elements of augmented matrix row-wise:\n\n");
for(a=1; a<=n; a++)
{
for(b=1; b<=(n+1); b++)
{
printf("A[%d][%d] : ", a,b);
scanf("%f",&A[a][b]);
}
}
for(b=1; b<=n; b++) /*upper triangular matrix*/
{
for(a=1; a<=n; a++)
{
if(a>b)
{
d=A[a][b]/A[b][b];
for(c=1; c<=n+1; c++)
{
A[a][c]=A[a][c]-d*A[b][c];
}
}
}
}
x[n]=A[n][n+1]/A[n][n];
/*backward substitution*/
for(a=n-1; a>=1; a--)
{
sum=0;
for(b=a+1; b<=n; b++)
{
sum=sum+A[a][b]*x[b];
}
x[a]=(A[a][n+1]-sum)/A[a][a];
}
printf("\nThe solution is: \n");
for(a=1; a<=n; a++)
{
printf("\nx%d=%f\t",a,x[a]); /* x1, x2, x3 are the required solutions*/
}
return(0);
}

OUTPUT

Thanks

Feel free to write back.Order of matrix:3 Enter the clements of augmonted matrix row-wise: 1 : 2.3 A[1] [2] : 一1.4 A1 3] : 4 AI21 :2 A121 [2]3 A[2] [

Add a comment
Know the answer?
Add Answer to:
Reposting since I got no answer last time. I need help with this gauss elimination program Hi, I need help with this program, it's an algorythm in R. I need it to be done in c. #suppose ak!...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need a program in c++ the same as below code but I want it to...

    I need a program in c++ the same as below code but I want it to prompt the user to enter the number of elements after that I want it to ask the user to enter the array elements #include<algorithm> #include<stdio.h> #include<string.h> #include<iostream> using namespace std; int a[50]={2,5,4,3}; bool x[100]; int N=4;//number of elements    int k=10;//target sum int sum;//current target sum int cmp(const void *a,const void *b) { return *(int *)b-*(int *)a; } void backtrace(int n) { if(sum>k) return...

  • hey I need help finishing this simplex program. public class Main {       /**       *...

    hey I need help finishing this simplex program. public class Main {       /**       * @param args       */       public static void main(String[] args) {             // TODO Auto-generated method stub             //FAIRE LES TODO dans Simplex             test1();test2();                   }       private static void test1() {             double[][] A = {                         { -1, 1, 0 },                         { 1, 4, 0 },                         { 2, 1, 0 },                         { 3, -4, 0 },                        ...

  • -I need to write a program in C to store a list of names (the last...

    -I need to write a program in C to store a list of names (the last name first) and age in parallel arrays , and then later to sort them into alphabetical order, keeping the age with the correct names. - Could you please fix this program for me! #include <stdio.h> #include <stdlib.h> #include <string.h> void data_sort(char name[100],int age[100],int size){     int i = 0;     while (i < size){         int j = i+1;         while (j < size){...

  • C++ HELP I need help with this program. I have done and compiled this program in...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • Hi, I need help with a fixed-point method program. It has to be done in C. The inputs are: Initia...

    Hi, I need help with a fixed-point method program. It has to be done in C. The inputs are: Initial approximation ρo, tolerance ε, and the maximum number of iterations MAXIT. The outputs are: Approximate solution ρ or "solution not found". STEP 1 Do i=1 STEP 2 While i≤ MAXIT, execute steps 3-6 STEP 3 Do ρ=ϕ(p) (calculate pi) STEP 4 If |ρ-ρo|<ε then output(ρ) (operation sucessful) END STEP 5 Do i=i+1 STEP 6 Do po=p (update po) STEP 7...

  • Hi! I really need help with this entire sheet as it's for a take home grade... please type or wri...

    Hi! I really need help with this entire sheet as it's for a take home grade... please type or write neatly in depth answer/explanation. Thanks! 5 20-4 -1313 4 16 -5-5 8 1 4-3 44 1 4 0 -5 0 0 01-3 0 Consider the matrix A = whose reduced echelon form is L0 00 00 Col A is a subspace of IRe for 2-.. . o dim Nul A- rank A dim Col A-.. A basis for Nul A...

  • Hello, i need help finding the time complexity(big0) for n..(java) a) for (int a = 0;...

    Hello, i need help finding the time complexity(big0) for n..(java) a) for (int a = 0; a < n; a = a + C) for (int b = 0; b < 10; b++) s[a] += b * s[a]; b) for (int a = 1; a < n; a = a * C) for (int j = 0; j < a; j++)    s[a] += j * s[a]; c)               for (int i = 1; i < n; i...

  • Need help with this C program? I cannot get it to compile. I have to use...

    Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...

  • please use octave calculator or matlab to answer (a)(ii)and(iii) 2. (a) Use Octave as a Calculator1 to answer this question. Suppose that A and B are two 8 × 9 matrices. The (i, j)-entry of the matri...

    please use octave calculator or matlab to answer (a)(ii)and(iii) 2. (a) Use Octave as a Calculator1 to answer this question. Suppose that A and B are two 8 × 9 matrices. The (i, j)-entry of the matrix B is given by i *j -1. The (i, j)-entry of the matrix A equals 0 if i + j is divisible by 5 and equals the (i, j)-entry of the matrix B otherwise. i. What are the rank and nullity of matrices...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT