Java prac 2

 import java.util.*;

class Main 

{

public static void main (String[] args) throws java.lang.Exception

{

    Scanner scan=new Scanner(System.in);

    System.out.println("Enter The Number of Rows:");

    int n=scan.nextInt();

    System.out.println("Enter the number of Cols:");

    int m=scan.nextInt();

    int[][] array=new int[n][m];

    for(int i=0;i<n;i++){

      System.out.println("Give The Values of row "+(i+1)+":");

      for(int j=0;j<m;j++){

      System.out.println("Give The Value of col "+(j+1)+":");

      array[i][j]=scan.nextInt();

      }

    }

    System.out.println("Array is Having ");

    for(int i=0;i<n;i++){

      System.out.println();

      for(int j=0;j<m;j++){

        System.out.print(array[i][j]+" ");

      }

    }

    System.out.println("\nProblem Finished");

  }

}


Comments

Popular posts from this blog

ONE TO ONE CHAT APP