```
# include<iostream>
using namespace std;
int const rows=3;    //rows are kept constant
int const cols=3;    //columns are kept constant

void display(int arr[][cols],int rows,int cols);    //function prototype
int rowsum(int arr[][cols],int rows,int cols);    //function prototype

int main()
{

    int z [rows][cols];    //2-D array declaration
    int r,c;

        for(r=0;r<rows;r++)
        {
            for(c=0;c<cols;c++)
            {
             cout<<"Enter elements of array["<<r<<"]["<<c<<"]:";
             cin>>z[r][c];
            }
        }
          display(z,rows,cols);    //Function call
          rowsum(z,rows,cols);    //Function call

        return 0;

}
void display(int arr[][cols],int rows,int cols)    //function to display input
{
    int r,c;
    for(r=0;r<rows;r++)
    {
     for(c=0;c<cols;c++)
      {
       cout<<"Elements of array["<<r<<"]["<<c<<"]="<<arr[r][c]<<endl;

      }
    }

}
int rowsum(int arr[][cols],int rows,int cols)    //Function to perform rowsum
{
    int c,sum=0,r=0;
    for(c=0;c<cols;c++)
    {
        sum=sum+arr[r][c];
        cout<<"the sum of rows is:"<<sum<<endl;
    }
    return sum;
}

```

Above is a C++ code which is using 2-D array.It takes input from user and that input is displayed using a display function.After taking input i want to sum the rows ,for which i have written a function named rowsum but it not working properly .It does not gives desired output.