How to sum the values of each row of an array and store the sum in an array ? Example:
3 3 3
2 3 4
2 2 2
Results in:
9
9
6
How to sum the values of each row of an array and store the sum in an array ? Example:
3 3 3
2 3 4
2 2 2
Results in:
9
9
6
I think you should start thinking about using a for
loop
Example to help ...
int[][] num = new int[3][3];
for (int i = 0; i < num.length; i++) {
int sum = 0;
for (int j = 0; j < num[i].length; j++) {
sum += num[j][i];
}
System.out.println(sum);
}