Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to read nine integer values from the user and save them in a

ID: 3861233 • Letter: W

Question

Write a C++ program to read nine integer values from the user and save them in a 3 times 3 matrix (2D array). Perform the following operations: 1. Display the values in a matrix format to the users. 2. Compute row summation of the matrix and display the values to the users. 3. Compute column summation of the matrix and display the values to the users. Sample Input: Enter the values in the matrix: 1 3 4 -2 5 -1 6 12 7 Sample Output: Given matrix: 1 3 4 -2 5 -1 6 12 7 Row summation: 8 2 25 Column summation: 5 20 10

Explanation / Answer

#include <iostream>

using namespace std;

int main() {

static int array[10][10];

int i, j, m, n, sum = 0;

cout<<"Enter the order of the matrix ";

cin>>m;

cin>>n;

cout<<"Enter the value of the matrix ";

for (i = 0; i < m; ++i)

{

for (j = 0; j < n; ++j)

{

cin>>array[i][j];

}

}

cout<<"Given matrix is "

for (i = 0; i < m; ++i)

{cout<<" ";

for (j = 0; j < n; ++j)

{

cout<<array[i][j]<<" ";

}

}

  

cout<<" row summation ";

for (i = 0; i < m; ++i)

{for (j = 0; j < n; ++j)

{

sum = sum + array[i][j] ;

}

cout<<sum<<" ";

sum = 0;

}

sum = 0;

cout<<" column summation ";

for (j = 0; j < n; ++j)

{

for (i = 0; i < m; ++i)

{

sum = sum + array[i][j];

}

cout<<sum<<" ";

sum = 0;

}

return 0;

}

//this is exactly what you want.

//i have run the code in my c++ compiler and it is working fine.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote