Monday, August 13, 2012

Source Code of Linear Equation Step by Step Solver in C Language

In the previous post, I have shared the executable of "program to solve system of linear equations with step by step solution". I got many requests from the readers to publish the source code. So I have rewritten the source code from scratch in C language. This version has a few impressive improvements than the previous one. In this article, we shall have a brief introduction to this program with a screenshot tour. The download links for the executables along with the source code are available for download on my facebook page.


I have written this program this program in C and compiled with GCC on Linux (Ubuntu). As I am giving you the source code of it, you can use it on any platform of your choice by compiling for that platform.

This program takes the inputs describing the system of linear equations in the form of an Augmented matrix and then solves for the solution using Gaussian elimination method also called as Gauss-Jordan Elimination method. Then it provides the solution set for the unknown variables of the given set of linear equations. I have already explained the math of it in brief in my previous article.

In this version, it also writes all the steps into a text file named "LINEQSOL.TXT" in the current working directory so that it will be easier for you to save the solution for future use.


Here is the screenshot of the start screen.
Screenshot-1. Start Screen of Linear Equation Solver

After starting the program, you will need to enter the number of variables that exist in the system of linear equations you want to solve (For example, give it as 3 ).

Next, it will prompt you to enter the augmented matrix. I have entered the same augmented matrix that I have illustrated earlier.

Screenshot-2. Result of System of Linear Equations along with Steps

It will then take the inputs, then computes and displays all the steps of the solution on the screen as shown in Screenshot-2. Then it now asks if you have another solution to be computed or not. If you have any, type 'Y', else type 'N'.

Screenshot-3. Result Printed to File LINEQSOL.TXT


All these steps are also saved in a file named "LINEQSOL.TXT" which is created in the current working directory. You may rename this file to prevent modification by the program when another solution is computed.


License:

This program is published under the GNU General Public License  v3.0.



Download :

The download file linear-equations-solver-v2.zip contains (size ~ 7.2kB):
  • LINEQSOL.C        (size ~ 6.8kB)
    Source code for this program
  • lineqsol-linux      (size ~ 11.6kB)
    Linux executable to run this program
  • Readme.txt          (size ~ 758bytes)
    This file describes this program in brief for user information.
You can view or download the source code and executables from my facebook page.

No comments:

Post a Comment