Write a program to print addition of two metrix
public class Addmetrix {
public static void main(String[] args)
{
int a[][]={{3,4,2},{4,5,6},{7,8,9}};
int b[][]={{3,4,2},{4,1,2},{7,8,9}};
int add[][]=new int[3][3];
for (int i=0;i<a.length;i++){
for (int j=0;j<b.length;j++){
add[i][j]=0;
for (int k=0;k<add.length;k++){
add[i][j]=a[i][k]+b[k][j];
}
System.out.print(add[i][j]+" ");
}
System.out.println();
}
}
}
OUTPUT :
>Next : Click for more metrix programs.
Start with your Choice
Sorting and Searching Programs
Learn Pattern Programs
public class Addmetrix {
public static void main(String[] args)
{
int a[][]={{3,4,2},{4,5,6},{7,8,9}};
int b[][]={{3,4,2},{4,1,2},{7,8,9}};
int add[][]=new int[3][3];
for (int i=0;i<a.length;i++){
for (int j=0;j<b.length;j++){
add[i][j]=0;
for (int k=0;k<add.length;k++){
add[i][j]=a[i][k]+b[k][j];
}
System.out.print(add[i][j]+" ");
}
System.out.println();
}
}
}
OUTPUT :
Write a program to print Multiplication of two metrix
public class Mulmetrix {
public static void main(String[] args)
{
int a[][]={{3,4,2},{4,5,6},{7,8,9}};
int b[][]={{3,4,2},{4,1,2},{7,8,9}};
int add[][]=new int[3][3];
for (int i=0;i<a.length;i++){
for (int j=0;j<b.length;j++){
add[i][j]=0;
for (int k=0;k<add.length;k++){
add[i][j]=a[i][k]*b[k][j];
}
System.out.print(add[i][j]+" ");
}
System.out.println();
}
}
}
OUTPUT :
Write a program to print Subtraction of two metrix
public class Submetrix {
public static void main(String[] args)
{
int a[][]={{3,4,2},{4,5,6},{7,8,9}};
int b[][]={{3,4,2},{4,1,2},{7,8,9}};
int add[][]=new int[3][3];
for (int i=0;i<a.length;i++){
for (int j=0;j<b.length;j++){
add[i][j]=0;
for (int k=0;k<add.length;k++){
add[i][j]=a[i][k]-b[k][j];
}
System.out.print(add[i][j]+" ");
}
System.out.println();
}
}
}
OUTPUT :
>Next : Click for more metrix programs.
Click to learn Array Programs
- 4 ways to print Array in Java
- 2D Array in Java
- Anonymous Array in Java
- Single Dimensional Array in Java
- Find Second Largest Number in Array
- Delete an Element in Array in Java
- Common Element in Array in Java
- Missing Element in Array
- Insert Element in Array
- Smallest and Largest Elements in Array
- Find Odd and Even Number in Array
-Important Programs for Freshers
Sorting and Searching Programs
Learn Pattern Programs
- Alphabet pattern program in java
- Square pattern programs in java
- Diamond Star pattern programs in java
- Number Pattern Programs in java
- Diagonal pattern program in java
Click to Learn MySQL
for any complaint regarding my Blog please visit contact us page and write what problem you have!
No comments:
Post a Comment