Sum All Row in the Array

PHOTO EMBED

Tue Jun 06 2023 22:46:25 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

public static void main(String[] args) {
		
		int [][] array = {
				{1,2,3,4,5},
				{6,7,8,9,10},
				{11,12,13,14,15},
				{16,17,18,19,20},
		};
		for(int row =0; row < array.length; row ++) {
			int total = 0;
			for(int column = 0; column < array[0].length; column++) {
				total = total + array[row] [column];
			}
			System.out.println("Sum for Row " + row + " , is = " + total);
		}
	}

//OUTPUT:

Sum for Row 0 , is = 15
Sum for Row 1 , is = 40
Sum for Row 2 , is = 65
Sum for Row 3 , is = 90
content_copyCOPY