Create a java programe to add two matrices of size 2 X 3 . java array
// Create a java program to add two matrices .
public class nilesh {
public static void main (String args[]){
int [][] mat1= { {1,2,2}, // First matrics
{1,1,2} };
int[][] mat2={{5,5,2}, // Second matrics.
{1,2,2}};
int [][] res ={{0,0,0},
{0,0,0}};
for (int i=0; i<mat1.length; i++){ // i is for rows
for (int j=0; j<mat1[i].length; j++){ // j is for columns
res[i][j]=mat1[i][j]+mat2[i][j];
System.out.print(res[i][j]+ " ");
}
System.out.println("");}
}}j
Comments
Post a Comment