Hello all. I am designing a Gauss jordan elimination program using c++. I need a little help to code this as I am not too familiar with arrays and the operations you can perform on them.(adsbygoogle = window.adsbygoogle || []).push({});

The first question I have is how would I swap rows? I know its probably really simple but I cannot find and source code that might provide some insight. Could anyone please take a look at the following code and give me some insights. Thanks in advance

This is just what I have so far.

Code (Text):

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

double x[50],a[50][50],c[50],d[50][50],max,loc;

int i,j,n,ai;

cout <<"\n\nPlease enter the number of rows/variables\n";

cin >> n;

cout<<"\nLet's now enter the row and column values\n"<<endl;

cout<<endl;

for (i=1;i<=n;i++)

{

for (j=1;j<=n;j++)

{

cout <<"Row "<<i<<", Column "<<j<<"\n";

cin >> a[i][j];

}

cout << "Please enter the constant for row "<<i<<"\n";

cin >> c[i];

}

cout <<"\n\nThe matrix entered is as follows:\n";

for (i=1;i<=n;i++)

{

cout<<"\n";

for (j=1;j<=n;j++)

{

cout <<a[i][j]<<"\t";

}

cout<<" ="<<c[i]<<"\n";

}

//looks for the pivot

max <= a[0][0];

loc <= 0;

for (i=1;i<=n;i++)

{

if (a[i][0] > max);

{

max <= a[i][0];

loc <= i;

}

}

system("pause");

return 0;

}

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Arrays c++

Loading...

Similar Threads for Arrays |
---|

Java Representation of two-dimensional arrays in the memory |

Python Array Indexing |

C/++/# Allocating a huge boolean array fails |

C/++/# Library that supports multidimensional Arrays |

C/++/# Arrays/vectors without knowing type |

**Physics Forums | Science Articles, Homework Help, Discussion**