-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.java
More file actions
30 lines (29 loc) · 768 Bytes
/
Matrix.java
File metadata and controls
30 lines (29 loc) · 768 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
29
30
import java.util.Scanner;
public class Matrix
{
public static void main(String ar[])
{
Scanner s=new Scanner(System.in);
System.out.println("Enter rows and columns");
int r = s.nextInt();
int c = s.nextInt();
int a[][] = new int[r][c];
System.out.println("Enter the elements of the Matrix");
for(int i=0; i<r;i++)
{
for(int j=0;j<c;j++)
{
a[i][j] = s.nextInt();
}
}
System.out.println("Elements of the Matrix are : ");
for(int i=0; i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(a[i][j] + " ");
}
System.out.print("\n");
}
}
}