java program to print a matrix in 2d array

      No Comments on java program to print a matrix in 2d array

Print a Matrix

This program illustrate the concept to print a matrix.

  • Matrix is a rectangular array arranged in rows and coloumns.
  • Suppose a matrix “A” is denoted by m x n order.Where m=rows and n=coloumns.
  • Here in this program i=number of rows in matrix.
  • j=number of coloumns in matrix.
import java.util.*;
class scan
{
 public static void main(String arg[])
  {
   int  a[][]=new int[3][3];
   int i,j;
   Scanner kb=new Scanner(System.in);
   
   System.out.println("Enter Matrice row wise:-");
 
 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
    a[i][j]=kb.nextInt();
    }
  }
  System.out.println("Entered Matrice is:-\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
   System.out.print(" "+a[i][j]);
 
    }
    System.out.println();
  }
  }
}

OUTPUT:-

print a matrix


Comment below if you are facing any problem.


h4>Also read

How to add two matrice in java
How to transpose a entered matrice in java program
Java program to multiply entered matrix


Summary
java program to print a matrix in 2d array
Article Name
java program to print a matrix in 2d array
Description
This program illustrate the concept to print a matrix.Suppose a matrix “A” is denoted by m x n order.Where m=rows and n=coloumns.
Author
Publisher Name
Scanfcode
Publisher Logo

Leave a Reply

Your email address will not be published. Required fields are marked *