Sunteți pe pagina 1din 4

1/13/2015

CProgramforGaussEliminationMethod|CodewithC

Tuesday, January 13, 2015

C Tutorial

Numerical Methods

Algorithms & Flowcharts

How To ?

Search...

Code with C
MiniProjects

SourceCode

StudentProjects

C++Code

C Program for Gauss Elimination Method


34%

March 28, 2014

34%

in Numerical Methods

5 Comments

In engineering and science, the solution of


linear simultaneous equations is very
important. Different analysis such as electronic
circuits comprising invariant elements, a
network under steady and sinusoidal
condition, output of a chemical plant and
finding the cost of chemical reactions in such
plants require the solution of linear
simultaneous equations.

29%

34%

29%

In Gauss-Elimination method, these equations


are solved by eliminating the unknowns
successively. The C program for Gauss
elimination method reduces the system to an

29%

upper triangular matrix from which the


unknowns are derived by the use of backward substitution method.
Pivoting, partial or complete, can be done in Gauss Elimination method. So, this method is somewhat
superior to the Gauss Jordan method. This approach, combined with the back substitution, is quite
general. It is popularly used and can be well adopted to write a program for Gauss Elimination Method
in C.

Final Year Projects

Java Projects

For this, let us first consider the following three equations:


ASP.NET Projects
Android Projects
PHP Projects
VB.NET Projects

C++ Projects

C Projects

Downloads

a1x + b1y + c1z = d1


a2x + b2y + c2z = d2
a3x + b3y + c3z = d3

Find us on Facebook
Codewithc.com

Assuming a1 0, x is eliminated from the second equation by subtracting (a2/ a1) times the first equation
from the second equation. In the same way, the C code presented here eliminates x from third equation
by subtracting (a3/a1) times the first equation from the third equation.

Like

780peoplelikeCodewithc.com.

AIPMT Question Bank


2015
Get AIPMT Question Bank To
Revise Weakest Concepts From All
Chapters.

Facebooksocialplugin

Popular

Recent

Comments

Tags

Hospital Management System


Project in C
May 23, 2014

Then we get the new equations as:


a1x + b1y + c1z = d1
b2y + c2z = d2
c3z = d3
The elimination procedure is continued until
only one unknown remains in the last
equation. After its value is determined, the
procedure is stopped. Now, Gauss
Elimination in C uses back substitution to
get the values of x, y and z as:
z= d3 / c3
y=(d2 c2z) / b2
x=( d1- c1z- b1y)/ a1

C/C++ Projects & Mini Projects with Source Codes

http://www.codewithc.com/cprogramforgausseliminationmethod/

1/4

1/13/2015

CProgramforGaussEliminationMethod|CodewithC

SourceCodeforGaussEliminationMethodin
C:

Download
May 3, 2014

Payroll Management System Project


in C++
July 22, 2014

How to include graphics.h in


CodeBlocks?
April 17, 2014

Mini Project in C Snake Game


April 4, 2014

C Program for Gauss Elimination Method


C
1 #include<stdio.h>
2 int main()
3 {
4
int i,j,k,n;
5
float A[20][20],c,x[10],sum=0.0;
6
printf("\nEnter the order of matrix: ");
7
scanf("%d",&n);
8
printf("\nEnter the elements of augmented matrix row-wise:\n\n");
9
for(i=1; i<=n; i++)
10
{
11
for(j=1; j<=(n+1); j++)
12
{
13
printf("A[%d][%d] : ", i,j);
14
scanf("%f",&A[i][j]);
15
}

16
}
17
for(j=1; j<=n; j++) /* loop for the generation of upper triangular matrix*/
18
{
19
for(i=1; i<=n; i++)
20
{
21
if(i>j)
22
{
23
c=A[i][j]/A[j][j];
24
for(k=1; k<=n+1; k++)
25
{
26
A[i][k]=A[i][k]-c*A[j][k];
27
}
28
}
29
}
30
}
31
x[n]=A[n][n+1]/A[n][n];
32
/* this loop is for backward substitution*/
33
for(i=n-1; i>=1; i--)
34
{
35
sum=0;
36
for(j=i+1; j<=n; j++)
37
{
38
sum=sum+A[i][j]*x[j];
39
}
40
x[i]=(A[i][n+1]-sum)/A[i][i];
41
}
42
printf("\nThe solution is: \n");
43
for(i=1; i<=n; i++)
44
{
45
printf("\nx%d=%f\t",i,x[i]); /* x1, x2, x3 are the required solutions*/
46
}
47
return(0);
48 }

Input/Output:

Also see,

Gauss Elimination Algorithm and Flowchart


Numerical Methods Tutorial Compilation
The source code for Gauss Elimination in C needs to compiled in Code::Blocks. The program is tested and
is bug-free. If you have any queries regarding Gauss Elimination Method or its program aforementioned,
bring them up from the comments box.

http://www.codewithc.com/cprogramforgausseliminationmethod/

2/4

1/13/2015

CProgramforGaussEliminationMethod|CodewithC

DownloadSourceCode
C++Code
ScienceProjects

Share !

Tweet

Like

Share

Previous:

Next:

C Program for Fixed Point Iteration


Method

C Program for Gauss-Jordan Method

5 comments
Patrik
December 16, 2014 at 8:08 pm

Please, what is meaning of: x[n]=A[n][n+1]/A[n][n]; I dont get it


Reply

Anonymous
November 26, 2014 at 7:32 pm

Can you also include the function of partial pivoting in this program?
Reply

Pavan
September 4, 2014 at 12:36 pm

your program is not working for some special matrices , u should improve the program in such a way that
it has to work for all types of matrices
Reply

Pramesh Pudasaini
September 4, 2014 at 1:32 pm

Really? What do you mean by some special matrices?


Reply

PassingBy
November 30, 2014 at 10:50 am

E.g. matrix, where at some point element on the main diagonal will be equal 0.
You should try https://en.wikipedia.org/wiki/Elementary_matrix#Operations
Reply

Leave a Reply
Your email address will not be published. Required fields are marked *
Name *

Email *

Website

PostComment

http://www.codewithc.com/cprogramforgausseliminationmethod/

3/4

1/13/2015

CProgramforGaussEliminationMethod|CodewithC

Home|AboutUs|ContactUs|PrivacyPolicy|TermsofUse
Copyright20142015CodewithC.Allrightsreserved.

http://www.codewithc.com/cprogramforgausseliminationmethod/

4/4

S-ar putea să vă placă și