Here i have written a C++ code which uses 2-dimension array and meant to perform rowsum but it is not giving proper output : <pre><code># include&lt;iostream&gt;
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&lt;rows;r++)
        {
            for(c=0;c&lt;cols;c++)
            {
             cout&lt;&lt;"Enter elements of array["&lt;&lt;r&lt;&lt;"]["&lt;&lt;c&lt;&lt;"]:";
             cin&gt;&gt;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&lt;rows;r++)
    {
     for(c=0;c&lt;cols;c++)
      {
       cout&lt;&lt;"Elements of array["&lt;&lt;r&lt;&lt;"]["&lt;&lt;c&lt;&lt;"]="&lt;&lt;arr[r][c]&lt;&lt;endl;

      }
    }

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

<p>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.</p>
