1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <iostream>
using namespace std;
int main(){
int sum = 0;
int array [8][5]={
{12,14,13,14,15},
{17,13,14,13,13},
{13,13,14,13,13},
{19,13,14,17,13},
{13,15,14,13,16},
{13,14,14,16,13},
{13,17,14,18,13},
{16,13,15,19,12}};
for (int row=0;row<8;row++){
for (int column=0;column<5;column++){
cout<< array [row][column] <<" ";
}
cout << endl;
}
// finding the row sum
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 5; ++j) {
// Add the element
sum = sum + array[i][j];
}
// Print the row sum
cout
<< "Sum of the row "
<< i << " = " << sum
<< endl;
// Reset the sum
sum = 0;
for (int a=8;a>=0;a--) {
for (int b=5;b>=0;b--) {
sum = sum + array[a][b];
}
cout
<< "Sum of the row "
<< i << " = " << sum
<< endl;
// Reset the sum
sum = 0;
}
}
}
/////////////////////////////
| |