Multiplication of two Matrics in JAVA
//Code for multiplication of two matrics in JAVA
package SolveProblem;
import java.util.Scanner;
public class MultiplicationOfTwoMatrics {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
int m,n,p,q;
int first[][]=new int[10][10];
int second[][]=new int[10][10];
int result[][]=new int[10][10];
System.out.println("Enter first matrics row and column : ");
m=myScanner.nextInt();
n=myScanner.nextInt();
System.out.println("Enter second matrics row and column : ");
p=myScanner.nextInt();
q=myScanner.nextInt();
if (n!=p) {
System.out.println("Multiplication impossible , Please enter valid num :");
} else {
System.out.println("Enter first matrics :");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
first[i][j]=myScanner.nextInt();
}
}
System.out.println("Enter second matrics :");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
second[i][j]=myScanner.nextInt();
}
}
int sum=0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < q; j++) {
for (int j2 = 0; j2 < p; j2++) {
sum=sum+(first[i][j2]*second[j2][j]);
}
result[i][j]=sum;
sum=0;
}
}
System.out.println("Multiplication of the given matrics is : ");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(result[i][j]+"\t");
}
System.out.println();
}
}
}
}
Click any Bellow Tabs/Tags
Alamgir-Hossain
(14)
Algorithms
(5)
Android problem
(2)
ANN
(1)
ArticleWriting
(26)
Artificial Intelligence
(1)
Assembly
(1)
Bangla Love Poem
(3)
Bangla Poem
(2)
best programming solution
(9)
Books
(2)
BUET IICT MSC Admission
-2021
(1)
C
(49)
Campus
(7)
CPP
(88)
Database
(4)
Differences
(2)
Fishing
(1)
HSC
(1)
Html
(4)
interesting programming solution
(9)
Interview
(2)
It job preparation
(7)
JAVA
(97)
JavaScript
(5)
JSON
(1)
lead generation
(1)
machine learning
(2)
ML Projects
(3)
NewsPaper
(19)
Others
(13)
Perl
(23)
Php
(4)
Poem
(4)
Presentation
(1)
ProblemSolving
(3)
Project
(21)
Prolog
(13)
Python
(33)
research
(18)
Research Tool
(1)
Security
(3)
Social Engineering
(1)
Testimonials
(5)
Tutorial
(2)
Writings
(15)
XML
(1)
YoutubeSEO
(1)
উক্তি
(1)
কবিতা-আলগীর হোসেন
(2)
লেখনী
(33)
LATEST
3-latest-65px
Popular Posts
-
All instructions for connection & insert data in mysql from java JSP and Servlet using tomcat serverFrom this tutorial you can learn about... All instructions for connection & insert data in mysql from java JSP and Servlet using tomc...
-
% Prolog program for addition and multplication-------- % Alamgir Hossain % CSE, JUST go :- write ( 'Enter first number : ' ...
-
Inverse Lagrange’s Interpolation Formula Theory : . Example : 1. Use Lagrange’s inverse interpolation fo...
-
Project Name : Online examination system. Framework : MVC framework in java(3 layer architecture). Language: JAVA JSP, SERVLET, JS...
-
Here is the source code for online exam system using PHP, MYSQL,AJAX, JAVASCRIPT etc.... Source code for Online Exam System
No comments:
Post a Comment