Respuesta :

Answer:

Here is code in c++.

#include <bits/stdc++.h>

using namespace std;

int main() {

//declare array of size 5x5

int arr[5][5];

// variables to store row sum and column sum

int row_sum=0,col_sum=0;

cout<<"please enter the elements of the array: "<<endl;

//reading elements of the array

for(int i=0;i<5;i++)

{

    for(int j=0;j<5;j++)

    {

        cin>>arr[i][j];

    }

    cout<<endl;

}

cout<<"\nsum of each row:"<<endl;

for(int i=0;i<5;i++)

{

    row_sum=0;

    for(int j=0;j<5;j++)

    {

    //calculating sum of each row

        row_sum=row_sum+arr[i][j];

    }

    //printing the sum of each row

    cout<<"sum of row "<<i+1<<" is :"<<row_sum<<endl;

}

cout<<"sum of each column :"<<endl;

for(int i=0;i<5;i++)

{

    col_sum=0;

    for(int j=0;j<5;j++)

    {

         //calculating sum of each column

        col_sum=col_sum+arr[j][i];

    }

    //printing the sum of each column

    cout<<"sum of column "<<i+1<<" is :"<<col_sum<<endl;

}

return 0;

}

Explanation:

Declare an array of integer type of size 5x5 to store the element from the user. Read the elements from the user.First travers the array row by row and find the sum of each row and print them.After that travers the array column by column and find the sum of each column and print them.

Output:

please enter the elements of the array:                                                                                                                        

23 43 55 23 78                                                                                                                                                                                                                                                                                                             52 64 88 43 56                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  23 56 343 76 61                                                                                                                                                                                                                                                                                                                           59 34 67 90 98                                                                                                                                                                                                                                                                                                                           99 12 3 7 123                                                                                                                                                              

                                                                                                                                                             

sum of each row:                                                                                                                                              

sum of row 1 is :222                                                                                                                                          

sum of row 2 is :303                                                                                                                                          

sum of row 3 is :559                                                                                                                                          

sum of row 4 is :348                                                                                                                                          

sum of row 5 is :244                                                                                                                                          

sum of each column :                                                                                                                                          

sum of column 1 is :256                                                                                                                                        

sum of column 2 is :209                                                                                                                                        

sum of column 3 is :556                                                                                                                                        

sum of column 4 is :239                                                                                                                                        

sum of column 5 is :416

ACCESS MORE