Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.

Thursday, March 29, 2012

WAP of Matrix Multiplication in Java


/*WAP of Matrix Multiplication in Java*/
import java.lang.*;
import java.io.*;
import java.util.*;
class matrix
{
 public static void main (String args[]) throws IOException
 {
  int a[][] = new int[2][2];
  int b[][] = new int[2][2];
  int c[][] = new int[2][2];
  
  Scanner sc = new Scanner(System.in);
  System.out.println("Enter Elements of Matrix 1");
  for(int i=0; i<2; i++)
  {
   for(int j=0; j<2; j++)
   {
   a[i][j] = sc.nextInt();
   }
  }

  System.out.println("Enter Elements of Matrix 2");
  for(int i=0; i<2; i++)
  {
   for(int j=0; j<2; j++)
   {
   b[i][j] = sc.nextInt();
   }
  }
  // calculation
  for(int i=0; i<2; i++)
  {
   for(int j=0; j<2; j++)
   {
    for(int k=0; k<2; k++)
    {
   c[i][j] += a[i][k] * b[k][j];
    }
   }
  }
  System.out.println("Matrix After multiplication");
  for(int i=0; i<2; i++)
  {
   for(int j=0; j<2; j++)
   {
   System.out.println( "\t" + c[i][j] );
   }
  }
 }
}

No comments:

Post a Comment

ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share