-
Notifications
You must be signed in to change notification settings - Fork 0
/
TakeArray.java
31 lines (25 loc) · 863 Bytes
/
TakeArray.java
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
28
29
30
31
import java.util.Arrays;
import java.util.Scanner;
public class TakeArray {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of rows : ");
int n = sc.nextInt();
System.out.print("Enter the number of columns : ");
int m = sc.nextInt();
int array[][] = new int[n][m];
System.out.println("Enter the elements of the array : ");
for(int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
array[i][j] = sc.nextInt();
}
}
System.out.println("Elements of the array are : ");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
System.out.print(array[i][j] + " ");
}
System.out.println();
}
}
}