×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Java Program to Exchange Odd Position Element with Even Position Element Write a Java program to transpose of a matrix.
Multiplication of two matrix - Java Program - Java
2868    Arnab De    06/04/2019

Write a Java program to calculate the Multiplication of two matrix.

Read two matrix as two 2D array. Now multiply the array elements as matrix.

Matrix Multiply
softetechnologies

import java.util.*;

class MatrixMultiply
{
	public static void main()
	{
		int arr1[3][3],arr2[3][3],arr3[3][3],i,j,k;
		Scanner sc=new Scanner(System.in);
		System.out.println("Enter The 1st Matrix Elements\n");
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				arr1[i][j]=sc.nextInt();
			}
		}	
		System.out.println("Enter The 2nd Matrix Elements\n");
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				arr2[i][j]=sc.nextInt();
			}
		}
		
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				arr3[i][j]=0;
				for(k=0;k<3;k++)
				{
					arr3[i][j] += arr1[i][k] * arr2[k][j];
				}
			}
		}
		
		System.out.println("\nFinal array Elements\n");
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				System.out.print(arr3[i][j] + "  ");
			}
			System.out.println("");
		}
	}
}
softetechnologies
softetechnologies
Java Program to Exchange Odd Position Element with Even Position Element Write a Java program to transpose of a matrix.
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Sri Sri Ramakrishna Paramahamsa
The world is needed a mixture of truth and make-believe. Discard the make-believe and take the truth.
Sri Sri Ramakrishna Paramahamsa
2246
60.53
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     44697
01/01/2018     36866
25/06/2018     36808
28/06/2017     34888
02/08/2017     33478
01/08/2017     27832
06/07/2017     27605
15/05/2017     27175
14/07/2017     22932
11/09/2018     21655
softetechnologies