Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define size 100 //define max size of colums and rows
- void columnSum(int arr[size][size], int m, int n)
- {
- int sum;
- for(int i = 0; i < n; i++)
- {
- sum = 0;
- for(int j = 0;j < m; j++)
- {
- sum = sum + arr[j][i];
- }
- cout << sum << endl;
- }
- }
- int main()
- {
- int arr[size][size], m ,n;
- cin >> m >> n; //input size of colums and rows
- for(int i = 0; i < m; i++)
- {
- for(int j = 0; j < n; j++)
- {
- cin>>arr[i][j];//input the array
- }
- }
- columnSum(arr, m ,n);//call function
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement