answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<conio.h>

void main(void)

{

int K, P, C, J;

double A[100][101];

int N;

int Row[100];

double X[100];

double SUM, M;

int T;

do

{

printf("Please enter number of equations [Not more than %d]\n",100);

scanf("%d", &N);

} while( N > 100);

printf("You say there are %d equations.\n", N);

printf("From AX = B enter elements of [A,B] row by row:\n");

for (K = 1; K <= N; K++)

{

for (J = 1; J <= N+1; J++)

{

printf(" For row %d enter element %d please :\n", K, J);

scanf("%lf", &A[K-1][J-1]);

}

}

for (J = 1; J<= N; J++) Row[J-1] = J - 1;

for (P = 1; P <= N - 1; P++)

{

for (K = P + 1; K <= N; K++)

{

if ( fabs(A[Row[K-1]][P-1]) > fabs(A[Row[P-1]][P-1]) )

{

T = Row[P-1];

Row[P-1] = Row[K-1];

Row[K-1] = T;

}

}

if (A[Row[P-1]][P-1] 0)

{

printf("The matrix is SINGULAR !\n");

printf("Cannot use algorithm --- exit\n");

exit(1);

}

X[N-1] = A[Row[N-1]][N] / A[Row[N-1]][N-1];

for (K = N - 1; K >= 1; K--)

{

SUM = 0;

for (C = K + 1; C <= N; C++)

{

SUM += A[Row[K-1]][C-1] * X[C-1];

}

X[K-1] = ( A[Row[K-1]][N] - SUM) / A[Row[K-1]][K-1];

}

for( K = 1; K <= N; K++)

printf("X[%d] = %lf\n", K, X[K-1]);

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Gaussian elimination in c
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which is more efficient for solving linear systems gaussian elimination or cramer's rule?

Of course, Gaussian Elimination!


What is the use of gaussian elimination in education world situations?

Gaussian elimination is used to solve systems of linear equations.


What are the real life applications of gaussian elimination?

none


Flow chart for gaussian elimination with partial pivoting?

gauss


What is the use of gaussian elimination in real world situations?

The gaussian elimination is used to solve many linear equations with many unknown varaibles at once. [See related link below to find out how to do it]. This is used alot by engineers you know ceratin variables in there structures and want to find out what the stress and strain is in certain areas. They make up there linear equations and then they can use the gaussian elimination method to find the unknown variables.


What is the difference between gauss elimination and gauss Jordan?

Gaussian elimination as well as Gauss Jordan elimination are used to solve systems of linear equations. If, using elementary row operations, the augmented matrix is reduced to row echelon form, then the process is called Gaussian elimination. If the matrix is reduced to reduced row echelon form, the process is called Gauss Jordan elimination. In the case of Gaussian elimination, assuming that the system is consistent, the solution set can be obtained by back substitution whereas, if the matrix is in reduced row echelon form, the solution set can usually be obtained directly from the final matrix or at most by a few additional simple steps.


What is the application of gaussian elimination?

It solves a system of equations. Think of the 2X2 case of having X+Y=1 and 3X+2Y=6.


What is the pseudocode of Gaussian elimination without pivoting?

Please visit the related link at the bottom. If I tried to write the computer algorithm here it would get very messy.


Who developed systems of equation?

The Chinese are believed to have started the development of systems of equation. They came up with a system for equation known as Gaussian elimination in 200 BC.


IF you need to solve large systems with more than three variables which method is more efficient and why?

For systems with more than three equations, Gaussian elimination is far more efficient. By using Gaussian elimination we bring the augmented matrix into row-echelon form without continuing all the way to the reduced row-echelon form. When this is done, the corresponding system can be solved by the back-substitution technique.


What kind of probabilistic distribution is followed by the random number generation function in C?

gaussian


What is gaussian filter in term of image processing?

the gaussian filter is also known as Gaussian smoothing and is the result of blurring an image by a Gaussian function.