Addition and Subtraction of Matrices
Addition and Subtraction of Matrices
Description:
This program is an array which the user needs to input 3 rows and 3 columns. This
array has a two sets of rows and columns which is matrix A and B. And user will choose
of the operations to solve the matrix. Addition and subtraction will be the operations of
this program. The process of solving will be like this the both of the first number
of matrices A and B will be added or subtract first, until the last number of matrices A and
B. The answer will be displayed the sum or difference of matrix A and B.
Source Code:
#include <iostream>
using namespace std;
int main ()
{
int a[3][3];
int b[3][3];
char operation;
cout<<"\n";
for ( int i = 0; i <3; i++ )
for ( int j= 0; j < 3; j++ )
{
cout << "2nd Matrix. Index:b[" << i << "] [" << j
<< "]: ";
cin >> b[i] [j];
}
cout <<"\nSelect an Operation: (+) or (-): " ;
cin >> operation;
Output:
Addition Subtraction