 # Gauss-Jordan Equation Method in C++

Subject Computer Science Computer Science - Other

## Question

Write a C++ program that can solve system of linear equations with Gauss-Jordan Method. There should be a system of linear equations in the input file "gauss.dat" in the form of matrices.

For example: the system of linear equations:
3x+5y+2z=1
3x+2y+7z=1
3x+6y+8z=1

In the input file:
3 <------ is the dimension of the matrix
1   3   5 2
1   3   2 7
1   3   6 8

You should get the matrices from the input file. Then solve the answer with Gauss-Jordan method.
The equations and the answers need to be put in the output file "gauss.txt".

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <string>

using namespace std;

void freeArray(int N, double **M){
// De-Allocate memory to prevent memory leak
for (int i = 0; i < N; i++)
delete [] M[i];
delete [] M;
}

double **AllocateArray(int N){
double **M;
M = new double*[N];
for (int i = 0; i < N; i++)
M[i] = new double[N+1];

return M;

}

// read of set of equations
int readOneSetOfEquations(int *Num, double ***M,istream &inFile, int toScreen){
char line;
int value;
string s;
stringstream ss;
*Num=0;
if(!inFile.eof()){
if ( toScreen ==1){
// from kdb
do{
cout << "Enter Number of rows ( from 2 to 9):";
cin>> value;
cin.clear();
cin.ignore(INT_MAX,'\n');
if(value <2 || value >9)
cout << "Error! Value must be in [2,9]"<< endl;
else
break;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

## Related Homework Solutions \$28.00
Computer Science
Modelling
Blue Flag
Management
Operators
Estimations
Targets
Services
Equipment
Motorists
Projects
Cases
Problems Using Programming Language C \$88.00
Computer Science
Programming
Algorithms
C
Structures
CSV Files
Pointers
Loops
Arrays
File Management
Variables
Statements
Input
Output
Tables
Memory Allocation
Strings
Integers
Why Cable TV Prefers FDM Over TDM \$10.00
Computer Science
Cable
TV
FDM
TDM
Frequency
Division
Multiplexing
Time
Signal
Data
Bandwidth
Destination
Allocation
Scheme
Telephone
C++ Questions \$25.00
Programming
C++
Computer Science
Objects
Variables
Private Members
Functions
Dollars
Cents
Codes
Statements
Complex Numbers
Arithmetic Operations
Data Fields
Input
Output
R Programming Problems \$18.00
Statistics
Probability
Computer Science
R Programming
Data Frames
Libraries
Columns
Classification
Genes
Biological Data Analysis
Leukemia
Properties
Stereo File Hard Drive Capacity \$5.00
Bit
khz
Stereo
File
Hard Drive
Samples
Per
Second
Depth
Computer Science
Space
Live Chats