Answer to Question #311857 in Java | JSP | JSF for EHSANSUNNY

Question #311857

:Calculate the sum of all elements in given matrix.



44 85 20 33 -18



56 35 67 -2 -54 45



44 42 56 -76 90



-56 78 -14 79 11 33 in java


1
Expert's answer
2022-03-15T02:58:18-0400
public class App{


     public static void main(String []args){
        
        
        int numbers[][]={{44,85,20,33,-18},{56,35,67,-2,-54,45},
        {44,42,56,-76,90},{-56,78,-14,79,11,33}};
        
        int sum=0;
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                System.out.print(numbers[i][j]+" ");
                sum+= numbers[i][j]; 
            }
            System.out.println();
        }
        
        System.out.println("Sum = "+sum);
     }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS