- 1
how to find sum of column of a 2d array in c++?
to find sum of all columns of array
4 Respuestas
+ 1
1 8 9
6 7 2
7 3 8
having the 2 dimenssion array int [][] a = new int[3][3];
a[0][0] = 1; a[0][1] = 8; a[0][2] = 3;
a[1][0] = 6; a[1][1]; a[1][2];
a[2][0] = 7; a[2][1] = 3; a[2][2] = 8;
for (int i = 0; i < 4; i ++){
for (int j = 0; j < 4;j++){
if (i == 1){
sum = sum + a[i][j];
}
}
This is an example to calculate the sum of the second column.
+ 1
yes, just remove the if condition
0
cant we find sum of all columns without finding sum of indivivual columns?
0
thanks