error in conversion of 2d array in C++ functions

  2d, arrays, c++
#include<iostream>
using namespace std;

int add(int x[2][2], int y[2][2],int z[2][2]);

int main()
{
   int a[2][2], b[2][2];
   cout << "Enter two matrices to add them " << endl;
   for (int i = 0; i < 2; i++)
   {
       for (int j = 0; j < 2; j++)
       {
           cin >> a[i][j];
       }
   }
   cout << endl;
   for (int i = 0; i < 2; i++)
   {
       for (int j = 0; j < 2; j++)
       {
           cin >> b[i][j];
       }
   }
   for(int i=0;i<2;i++)
   {
     for(int j=0;j<2;j++)   
     {
        cout<<add(a[2][2],b[2][2])<<endl;
     }
   }

    return 0;
}

int add(int x[2][2], int y[2][2],int z[2][2])
{
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            z[i][j] = x[i][j] + y[i][j];
        }
    }
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cout << z[i][j];
        }
        cout << endl;
    }

}


I wanted to build a function that take values from user and add then and show them on console screen,
it can be done easily but i want to make a fuction. I have build one shown above but it does not executes
it shows me error that invalid conversion from int to int.

Source: Windows Questions C++

LEAVE A COMMENT