We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc25513 commit 68d6555Copy full SHA for 68d6555
1 file changed
matrix.java
@@ -0,0 +1,30 @@
1
+import java.util.Scanner;
2
+public class matrix {
3
+ public static void main(String[] args) {
4
+ Scanner scanner = new Scanner(System.in);
5
+
6
+ System.out.print("Enter number of rows: ");
7
+ int rows = scanner.nextInt();
8
+ System.out.print("Enter number of columns: ");
9
+ int cols = scanner.nextInt();
10
11
+ int[][] matrix = new int[rows][cols];
12
13
+ System.out.println("Enter matrix elements:");
14
+ for (int i = 0; i < rows; i++) {
15
+ for (int j = 0; j < cols; j++) {
16
+ matrix[i][j] = scanner.nextInt();
17
+ }
18
19
20
+ System.out.println("The matrix is:");
21
22
23
+ System.out.print(matrix[i][j] + " ");
24
25
+ System.out.println();
26
27
28
+ scanner.close();
29
30
+}
0 commit comments