forked from avinashbest/java-coding-ninjas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputAndOutput.java
More file actions
27 lines (24 loc) · 860 Bytes
/
Copy pathInputAndOutput.java
File metadata and controls
27 lines (24 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package twoDimensionalArray;
import java.util.Scanner;
public class InputAndOutput {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter number of rows:");
int row = scan.nextInt();
System.out.println("Enter number of columns:");
int column = scan.nextInt();
int[][] arr = new int[row][column];
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
System.out.println("Enter the element at " + i + "th rows " + j + "th column:");
arr[i][j] = scan.nextInt();
}
}
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
System.out.print(arr[i][j] + "\t");
}
System.out.println();
}
}
}