Thursday, 21 January 2021

PROGRAM IN JAVA TO ADD 2 MATRICES [ DOUBLE DIMENSIONAL ARRAYS ]

 import java.util.*;

class DDA

{

  public static void main(String args[])

  {

  Scanner in=new Scanner(System.in); 

  int i,j,n;

  System.out.println("Enter the Size of the Matrix");

  n=in.nextInt();

  int a[][]=new int[n][n];

  System.out.println("Enter the elements of the Matrix");

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

  { 

  for(j=0;j<n;j++)

  a[i][j]=in.nextInt();

  }

  System.out.println("The Martix:");

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

  {

  for(j=0;j<n;j++)

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

  System.out.println();

  }

  }

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...