Feb 14, 2019 at 8:21am UTC
//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;
}
Feb 14, 2019 at 8:23am UTC
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
Feb 14, 2019 at 8:28am UTC
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 Feb 14, 2019 at 8:30am UTC
Feb 14, 2019 at 8:33am UTC
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 . . .
Feb 14, 2019 at 8:59am UTC
Hahahaha, that's great!!! Thanks for that, I just make double Mat[10][10] and it displays what I need.
Thank you, lastchance..,GB