-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray2D1.java
More file actions
28 lines (23 loc) · 754 Bytes
/
Array2D1.java
File metadata and controls
28 lines (23 loc) · 754 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
28
// This program takes input of a 3x3 matrix from the user
// and prints the matrix in row and column format
import java.util.Scanner;
public class Array2D1{
public static void main(String[] args) {
int matrix[][]=new int[3][3];
int n=matrix.length,m=matrix[0].length;
Scanner sc= new Scanner(System.in );
System.out.print("Enter matrix ");
for(int i=0;i<n;i++){
for (int j=0;j<m;j++){
matrix[i][j]=sc.nextInt();
}
}
//output
for(int i=0;i<n;i++){
for (int j=0;j<m;j++){
System.out.print(matrix[i][j]+ " ");
}
System.out.println( );
}
}
}