How to output Matrix here???

//Solving System of Linear Equations using loops

#include<iostream>
#include<iomanip>
#include<math.h>

using namespace std;

int main()
{
int r, c, n;
double Mat[r][c];

cout << "Enter the number of equations: ";
cin >> n;
cout << "\n";

cout << "Enter the coefficients row-wise" << endl;
for (r=0; r<n; r++)
{
for (c=0; c<n+1; c++)
{
cin >> Mat[r][c];
}
cout << endl;
}

for (r=0; r<n; r++)
{
for (c=0; c<n+1; c++)
{
cout << Mat[r][c] << " ";
}
cout << endl;
}
cout << endl;
return 0;
}
Good day, guys, I was just trying to make a simple program that will enable the user to input the elements of a matrix, then output it to show. But this simpleness makes me sick, hahaha, 'coz I can't output the matrix.

Please help.


Thanks in advance.


My code is this..,



Thanks,

emjaypee
So what input are you trying, for what (intended) output.


Your code wouldn't compile in a standards-compliant compiler.

At the moment you have less equations (n) than unknowns (n+1), so the best that will happen is your system is indeterminate.

Use code tags.
Last edited on
This is my output at CMD:



Enter the number of equations: 2

Enter the coefficients row-wise
7
1
5

3
0
2


7 3 0
3 0 2
Martin

--------------------------------
Process exited after 11.73 seconds with return value 0
Press any key to continue . . .
Have a look at your lines:
1
2
int r, c, n;
double Mat[r][c];


Even if you were allowed variable-length arrays (which you wouldn't be with a standards-compliant compiler), how big do you think your array Mat[][] is at this point?
Hahahaha, that's great!!! Thanks for that, I just make double Mat[10][10] and it displays what I need.

Thank you, lastchance..,GB
Topic archived. No new replies allowed.