Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions 2D_Array_Creation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import java.util.Scanner;

public class ArrayCreation2D {
public ArrayCreation2D() {
}

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the no. of rows and columns: ");
int nr = sc.nextInt();
int nc = sc.nextInt();
int[][] b = new int[nr][nc];

int i;
int j;
for(i = 0; i < nr; ++i) {
for(j = 0; j < nc; ++j) {
b[i][j] = sc.nextInt();
}
}

System.out.println("The elements are");

for(i = 0; i < nr; ++i) {
for(j = 0; j < nc; ++j) {
System.out.println(b[i][j]);
}
}

}
}