18 Feb 2021 2d Programs
18 Feb 2021 2d Programs
2D ARRAY
JAVA
Q1: ADDITION OF TWO MATRIX
import java.util.Scanner;
import java.util.Scanner;
To multiply two matrices in Java Programming, you have to first ask to the
user to enter the number of rows and columns of the first matrix and then
ask to enter the first matrix elements. Again ask the same for the second
matrix. Now start multiplying the two matrices and store the multiplication
result inside any variable say sum and finally store the value of sum in the
third matrix say multiply[ ][ ] at the equivalent index as shown in the
following program
CODE:
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int m, n, p, q, sum = 0, c, d, k;
Scanner in = new Scanner(System.in);
System.out.print("Enter Number of Rows and Columns of First Matrix : ");
m = in.nextInt();
n = in.nextInt();
int first[][] = new int[m][n];
}
}
THANK YOU