explain java code for 5*5 matrix
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] arr = new int[5][5];
int r = arr.length;
int c = arr[0].length;
System.out.println("Enter all 25 elements in the matrix:");
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
arr[i][j] = sc.nextInt();
}
}
System.out.println("--THE 5X5 MTARIX YOU ENTERED---");
for(int i = 0; i < r; i++){
for(int j = 0; j < c; j++){
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
Explanation:
Similar questions