This assignment was locked Oct 31 at 1159pm Compute the sum
This assignment was locked Oct 31 at 11:59pm. Compute the sum of rows and the sum of columns of a matrix. User input to populate the matrix with 3 rows and 3 columns and output should look like as it is shown in the example below. An example output should look like 12 3 6 4 5 6 15 7 8 9 24 12 15 18 Upload the source code
Solution
#include<iostream>
using namespace std;
int main()
{
int mat[3][3];
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
cout<<\"\ row \"<<i+1<<\"column \"<<j+1<<\" : \";
cin>>mat[i][j];
}
}
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
cout<<mat[i][j]<<\"\\t\";
}
cout<<mat[i][0]+mat[i][1]+mat[i][2];
cout<<\"\ \";
}
for(int k=0;k<3;k++)
{
cout<<mat[0][k]+mat[1][k]+mat[2][k]<<\"\\t\";
}
return 0;
}
