Here is the Java Program Multiplication Of Two Matrix
Checkout:- Java Program to Find Sum of Each Column of Matrix
Checkout:- Sum of Right Diagonal Elements of a Matrix
import java.util.*;
class Multiplication_of_two_Matrix
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of Rows");
int r=sc.nextInt();
System.out.println("Enter the number of Columns");
int c=sc.nextInt();
int arr[][]=new int[r][c];
int brr[][]=new int[r][c];
int crr[][]=new int[r][c];
System.out.println("Enter the elements of First Matrix");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
arr[i][j]=sc.nextInt();
}
}
System.out.println("First Matrix is :");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println("");
}
System.out.println("Enter the elements of Second Matrix");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
brr[i][j]=sc.nextInt();
}
}
System.out.println("Second Matrix is :");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(brr[i][j]+" ");
}
System.out.println("");
}
System.out.println("Third Matrix is :");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
crr[i][j]=arr[i][j]*brr[i][j];
System.out.print(crr[i][j]+" ");
}
System.out.println("");
}
}
}
------------
OUTPUT:-
------------
Enter the number of Rows
3
Enter the number of Columns
3
Enter the elements of First Matrix
1
5
2
3
6
4
7
8
9
First Matrix is :
1 5 2
3 6 4
7 8 9
Enter the elements of Second Matrix
5
2
3
6
4
7
8
9
6
Second Matrix is :
5 2 3
6 4 7
8 9 6
Third Matrix is :
5 10 6
18 24 28
56 72 54
----------------
Checkout:-Sum of Left Diagonal Elements of Matrix Java
0 Comments
Just write down your question to get the answer...