import java.*;
import java.io.*;
import java.util.*;

class Matrix
{
 public static void main(String arg[])
  {
   int m1[][]=new int[3][3];
   int m2[][]=new int [3][3];
   int re[][] =new int[3][3];
   int i,j,k;
   Scanner sc= new Scanner(System.in); 
   System.out.println("Enter First Matrix :");
    for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
       {
        System.out.print("Enter Element : ");
        m1[i][j] = sc.nextInt();       
        }

      }
   System.out.println("Enter Second Matrix :");
    for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
       {
        System.out.print("Enter Element : ");
        m2[i][j] = sc.nextInt();       
        }
      }
 
  System.out.println("Result Matrix :");
     for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
       {
        re[i][j] = 0;
          for(k=0;k<3;k++)
           {
            re[i][j] = re[i][j] + m1[i][j] *m2[i][j];
            }
        }
      }

    for(i=0;i<3;i++)
     {
      for(j=0;j<3;j++)
       {
        System.out.print(" "+re[i][j]);
        }
 System.out.println();
      }
   }
}
INPUT

Enter First Matrix :
Enter Element : 2
Enter Element : 2
Enter Element : 2
Enter Element : 2
Enter Element : 2
Enter Element : 2
Enter Element : 2
Enter Element : 2
Enter Element : 2

Enter Second Matrix :
Enter Element : 3
Enter Element : 3
Enter Element : 3
Enter Element : 3
Enter Element : 3
Enter Element : 3
Enter Element : 3
Enter Element : 3
Enter Element : 3

OUTPUT

18 18 18
18 18 18
18 18 18


Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA