Skip to content

Commit

Permalink
Added sum of rows of 2D array
Browse files Browse the repository at this point in the history
areenoverclouds committed May 25, 2021
1 parent 151738a commit 343ecaa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions SumofRows.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
using namespace std;

int main()
{
int i,j, m, n;
cout<<"\nEnter number of rows and coloumns : ";
cin>>m>>n;
int arr[m][n];
cout<<"\nEnter elements of matrix : \n";
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
cin>>arr[i][j];

cout << "\nFinding Sum of each row:";
int sum=0;

for (i = 0; i < m; ++i) {s
for (j = 0; j < n; ++j) {
sum = sum + arr[i][j];
}
cout<< "\nSum of the row "<< i << " = " << sum << endl;
sum = 0;
}

return 0;
}

0 comments on commit 343ecaa

Please sign in to comment.