1
    [this is for 4x4 matrix]
    [this one is for 3x4 matrix]   
    import java.util.Scanner;

        public class MyClass {
            public static void main(String args[]) {

                int num[][]= new int [4][4];
                Scanner obj = new Scanner (System.in);
                System.out.println("Enter values");
                for (int i=0;i<4;i++)
                {
                    for (int j=0;j<4;j++)
                    {
                        num[i][j]=obj.nextInt();
                    }
                }

               System.out.println("Your values");

               for (int i=0;i<3;i++)
               {
                   for (int j=0;j<4;j++)
                   {
                       System.out.print(num[i][j] + " ");
                   }
                   System.out.println();
                }
            }
        }

its not ending taking input for 4x4 matrix. but when i enter 2x2 or 3x4 it shows perfect output. i want to take 16 inputs but it keeps on taking inputs. I also wanna take separate inputs for each element i.e. enter value for row 1 and column 2 element. kindly help

      [1]: https://i.stack.imgur.com/tPKqY.png
      [2]: https://i.stack.imgur.com/g3bmg.png
ivpavici
  • 1,117
  • 2
  • 19
  • 30
ALi Raza Darr
  • 149
  • 1
  • 1
  • 9

0 Answers0