Computer Science, asked by drishtipandey05, 6 hours ago

Write a program to enter numbers in a 2-D array with n rows and m columns and print the sum of the elements in each row and each column.

Answers

Answered by kashvichaurasia819
1

Answer:

ANSWER

import java.util.Scanner;

public class KboatDDASum

{

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter number of rows (n): ");

int n = in.nextInt();

System.out.print("Enter number of columns (m): ");

int m = in.nextInt();

int arr[][] = new int[n][m];

System.out.println("Enter array elements");

for (int i = 0; i < n - 1; i++) {

System.out.println("Enter Row "+ (i+1) + " :");

for (int j = 0; j < m - 1; j++) {

arr[i][j] = in.nextInt();

}

}

Similar questions