TRANSPOSE IN C++

CODE:


#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
       int i,j,k[20][20],l[20][20];
       cout<<"Enter the value of matrix"<<endl;
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     cin>>k[i][j];
              }
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     cout<<k[i][j]<<"\t";
              }
              cout<<endl;
              }
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     l[j][i]=k[i][j];
              }
       }
       cout<<endl<<endl;
       for(i=0;i<2;i++)
       {
              for(j=0;j<2;j++)
              {
                     cout<<l[i][j]<<"\t";
              }
              cout<<endl;
       }
       getch();
       }

No comments:

Post a Comment