76 793
Assignments Done
Successfully Done
In June 2019

Answer to Question #47691 in C++ for rishi

Question #47691
write a COLSUM() function in c++ to find sum of each column o a N*M Matrix.
Expert's answer
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;
void ColSum(int **mas, int n, int m);
int main()
int n,m;
cout<<"Enter the n: ";
cout<<"Enter the m: ";
int **mas = new int* [n];
for (int i = 0; i < n; i++)
mas[i] = new int[m];
cout<<"Enter the array elements: (Array "<<n<<"*"<<m<<"):"<<endl;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ColSum(mas, n, m);
return 0;
void ColSum(int* mas[], int n, int m)
int sum = 0;

for (int j = 0; j < m; j++)
for (int i = 0; i < n;i++)
sum +=mas[i][j];
cout<<"Sum of "<<j+1<<" column: "<<sum<<endl;
sum = 0;


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions