/******* Java Implementation of Matrix Operation Using Arrays *******/
class Matrix
{
public static void main(String args[])
{
int i,j,k;
int mat1 [][]={ {10,11,12}, {13,14,15}, {16,17,18} };
int mat2 [][]={ {1,2,3}, {4,5,6}, {7,8,9} };
System.out.println("Operation ON Matrices \n1.Addition \n");
int sum [][] = new int [3][3];
for(i=0;i <3;i++)
{
for(j=0;j< 3;j++)
{
sum[i][j] = mat1[i][j] + mat2[i][j];
System.out.print("\t" + sum[i][j]);
}
System.out.println("\t");
}
System.out.println("2.Subtraction\n");
int diff[][] = new int[3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
diff [i][j] = mat1[i][j] - mat2[i][j];
System.out.print("\t"+ diff[i][j]);
}
System.out.println("\t");
}
System.out.println("3.Multiplication\n");
int prod[][] = new int[3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
prod[i][j] = 0;
{
for(k=0;k< 3;k++)
prod[i][j] = prod[i][j]+mat1[i][k]*mat2[k][j];
}
System.out.print("\t"+ prod[i][j]);
}
System.out.println("\t");
}
}
}
/************* OUTPUT ***************
Operation ON Matrices
1.Addition
11 13 15
17 19 21
23 25 27
2.Subtraction
9 9 9
9 9 9
9 9 9
3.Multiplication
138 171 204
174 216 258
210 261 312 */
Subscribe to:
Post Comments (Atom)
hello..it really helps us a lot...
hello...it really helps us a lot!!!!!...
THANK YOU VERY MUCH!
MORE POWER AND GOD BLESS!
thanks a lot.........
thank ye!!it helped me
thank ye!!it helped me
thnks u
thnks u
thnk u
thank u so much
need a program in which decimal number change into roman numbers
what abt division"?
really a helpful thanks a lot
Thanks a lot. It's very easy to understand.
its helps me a lot...
its very easy...
want div code,just like it..........easy.....................................................................
THANKS................................
prod[i][j] = 0;
{
for(k=0;k< 3;k++)
prod[i][j] = prod[i][j]+mat1[i][k]*mat2[k][j];
Explain the above logic
prod[i][j] = 0;
{
for(k=0;k< 3;k++)
prod[i][j] = prod[i][j]+mat1[i][k]*mat2[k][j];
Explain the above logic
this is very use full sight for java users
it is a good blog
all java users