3 Write a small code snippet that will give the two indices
Solution
import java.util.Scanner;
 public class test {
 public static void main(String[] args) {
 System.out.println(\"Hello, World!\");
       
        int[][] arr=new int[100][100];
        int row, col, i, j, element;
       
        Scanner in = new Scanner(System.in);
       
        System.out.println(\"Enter the size of matrix (maximum 100 x 100)\ \");
        row = in.nextInt();
        col = in.nextInt();
       
        System.out.println(\"\ Enter values of the matrix\ \");
        for(i = 0; i< row; i++)
            for(j = 0; j < col; j++)
            {
                arr[i][j] = in.nextInt();
                System.out.println(\"\ \");
            }
       
        System.out.println(\"\ The matrix is as follows\ \");
        for(i = 0; i< row; i++)
        {
            for(j = 0; j < col; j++)
            {
                System.out.print(arr[i][j] + \"\\t\");
            }
            System.out.println(\"\ \");
        }
           
        System.out.println(\"\ Enter the element whose indices need to be known\ \");
        element = in.nextInt();
        for(i = 0; i< row; i++)
            for(j = 0; j < col; j++)
            {
                if(arr[i][j] == element)
                System.out.println(\"\ Indices of the \" + element + \" are i = \" + i + \" and j = = \" + j + \"\  A[\" + i + \"][\" + j + \"]\");
            }
 }
 }
