Followers

Saturday, December 3, 2011

DOUBLE OF A MATRIX

#include<iostream.h>
#include<conio.h>

void main()
{
 int x[10][10], y[10][10], n, m, i, j;
 cout<<"\nEnter the number of rows :";
 cin>>n;
 cout<<"Enter the number of columns :";
 cin>>m;
 cout<<"Enter the matrix X :\n";
 for(i=0 ; i<n ; i++)
 {
   for(j=0 ; j<m ; j++)
     cin>>x[i][j];
 }

 cout<<"The matrix X :\n";
 for(i=0 ; i<n ; i++)
 {
   cout<<"\n";
   for(j=0 ; j<m ; j++)
     cout<<" "<<x[i][j];
 }


 for(i=0 ; i<n ; i++)
 {
   for(j=0 ; j<m ; j++)
     y[i][j]= 2*x[i][j];
 }
 cout<<"\nThe double of the given matrix : ";

 for(i=0 ; i<n ; i++)
 {
   cout<<"\n";
   for(j=0 ; j<m ; j++)
     cout<<" "<<y[i][j];
 }

 getch();
}
.................................................................
OUTPUT:(click to enlarge the image)

No comments:

Post a Comment