Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions RowWiseSum_2DArray.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <bits/stdc++.h>

using namespace std;

int main ()
{

int x,y;

cout << "Enter no. of row - "; cin >> x;

cout << "Enter no. of columns - "; cin >> y;



int arr[x][y];


cout << "Enter elements - " << endl;


for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {

cin >> arr[i][j];

}
cout << "\n";

}



cout << "\n - Sum of each row - \n\n";


for (int i = 0; i < x; ++i) {

int sum = 0;

for (int j = 0; j < y; ++j) {


sum = sum + arr[i][j]; // sum of rows

}

cout << "Sum of row " << i << " = " << sum << endl;


}


return 0;

}