0

I am trying to create a program which adds substracts two matrices. Using switch statements. I am not sure that I am making the correct function calls. I ve been struck on this for two days looking for some guidance. Please see below my code.

```
I am trying to create a program which adds substracts two matrices. Using switch statements. I am not sure that I am making the correct function calls. I ve been struck on this for two days looking for some guidance. Please see below my code.
#include<iostream>
#include<iomanip>
using namespace std;
int input (int [][2],int , int );
int output(int [][2], int, int );
int add ( int [][2], int, int );
int sub (int [][2], int , int );
int input2 (int [][2],int, int );
const int r=2, c=2;
int main ()
{
int mat[r][c], A;
input(mat, r, c);
output(mat, r,c);
cout<<"enter your choice 1.Add, 2. Sub \n";
cin>>A;
switch (A)
{
case 1:
add (mat, r, c);
break;
case 2:
sub (mat, r, c);
}
}
int input (int a[][2], int r , int c)
{
for (int i=0; i<r; i++)
for (int j=0; j<c; j++)
cin>>a[i][j];
return a[r][c];
}
int output (int b [][2], int r, int c)
{
for (int i=0; i<r; i++)
{
for (int j=0; j<c; j++)
{ cout<<setw(10)<<b[i][j];
}
cout<<endl;
}
return b[r][c];
}
int add (int b[][2], int r, int c)
{
int f[2][2];
input2 (f,2,2);
int g[2][2];
for (int r=0;r<2;r++)
for (int c=0;c<2;c++)
g[2][2] = f[r][c] + b[r][c];
output (g,2,2);
return g[2][2];
}
int sub (int e[][2], int r, int c)
{
int f[2][2];
int g[2][2];
input(f,2,2);
for (int r=0;r<2;r++)
for (int c=0;c<2;c++)
g[3][3] = f[r][c] - e[r][c];
output (g,2,2);
return g[2][2];
}
int input2 (int a[][2],int r, int c)
{
for (int i=0; i<r; i++)
for (int j=0; j<c; j++)
cin>>a[i][j];
return a[r][c];
}
```