1.

Write a definition for a function SUMMIDCOL(int MATRIX[ ] [10], int N, int M) in C++, which finds the sum of the middle column’s elements of the MATRIX (Assuming N represents number of rows and M represents number of columns, which is an odd integer).Example: If the content of array MATRIX having N as 5 and M as 3 is as follows:1212143455453532The function should calculate the sum and display the following:Sum of Middle Column: 15

Answer»

void SUMMIDCOL(int MATRIX[ ][10], int N, int M)

{

int j, SUM=0;

j=M/2:

for(int i=0: i<N;i++)

SUM + = MATRIX [i][j];

cout<<"SUM of MIddle Column : "<<SUM;

}



Discussion

No Comment Found

Related InterviewSolutions