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;
   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();       
        }
      }
 
    for(i=0;i<3;i++)
     {
      for(j=0;j<3;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 Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4

Enter Second Matrix - 
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4
Enter Element : 4

OUTPUT

8  8  8 
8  8  8 
8  8  8

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