i am supposed to represent matrices to solve simutaneous equations, add them, find inverse etc.
i am trying to help myself , but i am stuck.all i have managed to do so far is understand how to display a matrix. i am using borland C++. can someone show me how to add 2 matrices.
# include <iostream.h>
# include <math.h>
#include <conio.h>
void main()
{
int a,b,c,d,e,f,g,h,l ;
cout << "Enter a:" << endl;
cin >> a;
cout << "Enter b:" << endl;
cin >>b;
cout << "Enter c:" << endl;
cin >>c;
cout << "Enter d:" << endl;
cin >>d;
cout << "Enter e:" << endl;
cin >>e;
cout << "Enter f:" << endl;
cin >> f;
cout << "Enter g:" << endl;
cin >> g;
cout << "Enter h" << endl;
cin >> h;
cout << "Enter l" << endl;
cin >> l; // if you were to accidentally leave out one of the cins it would say possible l without definition...
Adding 2 matrices is easy. I see you can assign values to the elements ( as you did with table[][] by prompting the user for the values ). If you have 2 3x3 matrices M1 and M2 then you can add them to find the sum M3 = M1 + M2 by adding the corresponding elements.
1 2 3 4 5 6 7 8
int M1[3][3] = {{a,b,c},{d,e,f},{g,h,l}};// if M1 and M2 are given
int M2[3][3] = {{j,k,l},{m,n,o},{p,q,r}};
// find the sum
int M3[3][3];
for(int i =0; i<3; i++)// note that the braces may be omitted if there is only 1 instruction in the loop
for(int j = 0; j<3; j++)
M3[i][j] = M1[i][j] + M2[i][j];
NOTE: I'm a matrix specialist, can send you any code related to matrix, like addition, subtraction, multiplication, inverse(by the method you want), solving system of 2(or 3) equations, etc