0% found this document useful (0 votes)
6 views1 page

A1

Uploaded by

22eg107b07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

A1

Uploaded by

22eg107b07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;
class A{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int rsize= scan.nextInt();
int csize=scan.nextInt();
int[][] a=new int[rsize][csize];
System.out.print("enter elements");
for(int i=0;i<a.length;i++){
for(int j=0;j<a[i].length;j++){
a[i][j]=scan.nextInt();
}
}
int r1size= scan.nextInt();
int c1size=scan.nextInt();
int[][] b=new int[r1size][c1size];
System.out.print("enter elements");
for(int i=0;i<b.length;i++){
for(int j=0;j<b[i].length;j++){
b[i][j]=scan.nextInt();
}
}

System.out.println("1st matrix");
for(int i=0;i<a.length;i++){
for(int j=0;j<a[i].length;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
System.out.println("2nd matrix");
for(int i=0;i<b.length;i++){
for(int j=0;j<b[i].length;j++){
System.out.print(a[i][j]+" ");
}
System.out.println();
}
int[][] c=new int[rsize][csize]
System.out.println("resultant matrix is");
for(int i=0;i<rsize;i++){
for(int j=0;j<c1size;j++){
for(int k=0;k<csize;k++){
c[i][j]+=a[i][k]+b[k][i];
}
}
}
}
}

You might also like