Monday 3 June 2013

To check matrix is identity or not?
// addition of arrays

#include<iostream.h>
void main()
{
int a[3][3], b[3][3], c[3][3],  i, j;

// initializing 2 D array a with user defined values

cout<<"Enter values for array A"<<endl<<endl;

for(i=0;i<3;i++)
{
  for(j=0;j<3;j++)
  {
    cout<<"enter value for a["<<i<<"]["<<j<<"]:";
    cin>>a[i][j];
  }
}

cout<<endl<<endl;

// initializing 2 D array b with user defined values

cout<<"Enter values for array B"<<endl<<endl;

for(i=0;i<3;i++)
{
  for(j=0;j<3;j++)
  {
    cout<<"enter value for b["<<i<<"]["<<j<<"]:";
    cin>>b[i][j];
  }
}

cout<<endl<<endl;

// addition and displaying the sum

cout<<"A + B =:"<<endl<<endl;

for(i=0;i<3;i++)
{
  for(j=0;j<3;j++)
  {
  c[i][j] = a[i][j] + b[i][j];
    cout<<c[i][j]<<" ";
  }
cout<<endl;
}


}

0 comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!